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:
(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
(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.
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.
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
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
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