Re: Question, how to use virDomainQemuMonitorCommand()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 09, 2010 at 08:52:13AM -0400, Chris Lalancette wrote:
> On 09/09/10 - 04:52:25PM, Lai Jiangshan wrote:
> > On 09/07/2010 09:22 PM, Chris Lalancette wrote:
> > > On 09/07/10 - 04:08:13PM, Lai Jiangshan wrote:
> > >> Hi, Chris,
> > >>
> > >> I saw virDomainQemuMonitorCommand() in libvirt-qemu.c,
> > >> I think it will help me to send arbitrary qemu-monitor command to
> > >> qemu via libvirtd.
> > >>
> > >> But how can I use virDomainQemuMonitorCommand()?
> > >> Can I use it by just using current tools(virsh or other) without writing any code?
> > > 
> > > Unfortunately, no.  There is a bug in the current virsh command that prevents
> > > it from properly parsing the command-lines necessary to send monitor commands
> > > to the qemu monitor.  Until we fix that bug, we won't push the support into
> > > virsh.
> > > 
> > 
> > Thanks,
> > 
> > We need this feature, could you tell me the detail of the bug,
> > we will try to fix it or do assists.
> 
> I've outlined it before on this list, but the gist of it is that the way that
> virsh parses command-line arguments loses the formatting.  Thus, if you were
> enter a command like:
> 
> # virsh qemu-monitor-command f13guest "info cpus"
> 
> Then virsh main() will get 4 arguments:
> 
> argv[0] = "virsh";
> argv[1] = "qemu-monitor-command";
> argv[2] = "f13guest";
> argv[3] = "info cpus";
> 
> So far, all is good.  However, during the parsing of these command-line
> arguments, virsh takes all of these arguments and smashes them back together
> as a single string:
> 
> command = "virsh qemu-monitor-command f13guest info cpus";
> 
> And then it reparses the whole thing.  Notice that we've lost the quoting,
> though, so now it's an invalid command.
> 
> The problem is further complicated by some of the other features of virsh,
> including the support for separating multiple commands with semicolons.  For
> example, the following is a legal command:
> 
> # virsh 'define D.xml; dumpxml D'
> 
> In any case, the answer is probably to re-write the command-line parsing of
> virsh to not lose quoting.  I have not had time to do this, so if you have
> the time to look at it and make it work, patches are definitely appreciated!

While re-writing the command line mashing to not loose quotes would be
nice, the more obvious fix is to not mash all the args back into a
string at all. The virsh command ultimately wants char **argv, and we 
already have char **argv. So doing a char ** -> char * -> char **
conversion is just insanity.

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]