Bug 835476

Summary: RFE: virsh: add domxml-to-native --domain option (for existing VM)
Product: [Community] Virtualization Tools Reporter: David Jaša <djasa>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, jtomko, kkoukiou, rbalakri, srwx4096
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: LibvirtFirstBug
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-07 08:17:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Jaša 2012-06-26 09:53:50 UTC
Description of problem:
The only way to get e.g. qemu command line directly from existing domain is this ugly command:
virsh dumpxml winxp | virsh domxml-to-native qemu-argv /dev/stdin

because virsh as of now can't take domain as an argument:
  SYNOPSIS
    domxml-to-native <format> <xml>

Therefore I propose to modify domxml-to-native to accept domain name in addition to xml:
domxml-to-native <format> (<xml>|<domain>)

Version-Release number of selected component (if applicable):
libvirt-0.9.10-21.el6.x86_64

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 2 Dave Allan 2012-06-26 12:57:32 UTC
(In reply to comment #0)
> Description of problem:
> The only way to get e.g. qemu command line directly from existing domain is
> this ugly command:
> virsh dumpxml winxp | virsh domxml-to-native qemu-argv /dev/stdin

That's not the right way to get the qemu command line.  The qemu commandline that was executed for a running domain is logged into /var/log/libvirt/qemu/<domainname>.log

Comment 3 David Jaša 2012-06-26 13:30:42 UTC
(In reply to comment #2)
> That's not the right way to get the qemu command line.  The qemu commandline
> that was executed for a running domain is logged into
> /var/log/libvirt/qemu/<domainname>.log

That's not good approach when you need to fine-tune domain xml to get desired resulting command line.

Comment 4 Cole Robinson 2016-04-21 21:27:04 UTC
I think adding an explicit option like 'virsh domxml-to-native --domain id|name|uuid' is a good idea.

The command handling is in tools/virsh-domain.c cmdDomXMLToNative function. You'll want to add the common --domain option via VIRSH_COMMON_OPT_DOMAIN_FULL. If the explicit XML isn't passed, you'll need to fetch the XML via virDomainGetXMLDesc first.

Comment 5 srwx4096 2017-03-30 12:09:33 UTC
There were two different suggestions in this thread on how we would want to change the DOMAIN COMMAND "domxml-to-native". I need some guidance to help me make the decision.

After looking through man page of "virsh", I think there could be two or three possible solutions with different flavor. 

1. domxml-to-native <format> { --xml FILE | --domain DOMAIN }, where the usage of "--xml" is consistent with existing appearance in man-page of "virsh"; while introducing "--domain" is incoherent in that existing "virsh" man-page directly references <domain> wherever necessary without specifically mentioning with "--domain" prefix, which leading the second solution:

2. domxml-to-native <format> {FILE|DOMAIN}, which is compatible with existing command from user perspective, where we need to detect the input argument being either an XML file or a DOMAIN (domain id, uuid, or name). Just for the sake of practice, we could also have the following solution:

3. domxml-to-native <format> { [--xml] FILE | [--domain] DOMAIN }, in case someone really prefer to specify the input while also being compatible with existing style.

Dan

Comment 6 Cole Robinson 2017-03-30 17:53:08 UTC
We cannot change the current command semantics, so mandating an explicit --xml option isn't an option. So the options are to make one of these two work:

  virsh domxml-to-native qemu-argv $domname
  virsh domxml-to-native qemu-argv --domain $domname

I can't think of any commands that will take either a file path or domain name for a single field, seems kind of ambiguous. I suggest making the second example work. To make it work you may need to drop VSH_OPT_REQ flag for --xml, but fail in the code if xml or domain isn't specified

Comment 7 Katerina Koukiou 2018-06-07 08:17:41 UTC
Fixed upstream by:
commit 41eb92783e831b9362c321bd563c6c4ec592eb3d
Author: Daniel Liu <srwx4096>
Date:   Fri Jun 2 11:04:52 2017 -0400

    virsh: add [--domain DOMAIN] option to domxml-to-native DOMAIN COMMAND

git describe: v3.4.0-169-g41eb92783e