Bug 835476 - RFE: virsh: add domxml-to-native --domain option (for existing VM)
RFE: virsh: add domxml-to-native --domain option (for existing VM)
Status: NEW
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
LibvirtFirstBug
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-26 05:53 EDT by David Jaša
Modified: 2017-03-30 13:53 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-06-26 08:57:32 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Jaša 2012-06-26 05:53:50 EDT
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 08:57:32 EDT
(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 09:30:42 EDT
(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 17:27:04 EDT
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 08:09:33 EDT
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 13:53:08 EDT
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

Note You need to log in before you can comment on or make changes to this bug.