[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] [Qemu-devel] Does qemu guest agent support 'guest-exe
From: |
Hu, Robert |
Subject: |
Re: [Qemu-discuss] [Qemu-devel] Does qemu guest agent support 'guest-exec'? |
Date: |
Wed, 2 Aug 2017 01:16:41 +0000 |
Best Regards,
Robert Hoo
> -----Original Message-----
> From: Michael Roth [mailto:address@hidden
> Sent: Wednesday, August 2, 2017 0:44
> To: Hu, Robert <address@hidden>; address@hidden; qemu-
> address@hidden
> Subject: Re: [Qemu-devel] Does qemu guest agent support 'guest-exec'?
>
> Quoting Hu, Robert (2017-08-01 02:15:01)
> > Hi,
> >
> > qemu/scripts/qmp/qemu-ga-client seems only support "cat, fsfreeze, fstrim,
> halt, ifconfig, info, ping, powerdown, reboot, shutdown, suspend".
> >
> > But from qemu/qga/commands.c seems at least Linux guest should already
> support this. Despite qemu-ga-client, how can I talk to guest-agent in guest
> to
> execute some program? any other utils?
>
> qemu-ga-client is more of a helper script to make it easier to execute things
> from cmdline and hasn't been updated to support guest-exec. But the official
> API is documented in qga/qapi-schema.json and involves talking to qemu-ga
> directly via JSON commands. A simple example for guest-exec would be
> something like:
>
> address@hidden:~$ sudo nc -U /tmp/vm3-qga.sock
> {'execute':'guest-exec','arguments':{'path':'ip','arg': ['addr', 'show',
> 'eth0'],'capture-output':true}}
> {"return": {"pid": 1462}}
> {'execute':'guest-exec-status','arguments':{'pid':1462}}
> {"return": {"exitcode": 0, "out-data":
> "MjogZXRoMDogPEJST0FEQ0FTVCxNVUxUSUNBU1QsVVAsTE9XRVJfVVA+IG10d
> SAxNTAwIHFkaXNjIHBmaWZvX2Zhc3Qgc3RhdGUgVVAgZ3JvdXAgZGVmYXVsdCB
> xbGVuIDEwMDAKICAgIGxpbmsvZXRoZXIgNTI6NTQ6MDA6MTI6MzQ6MDMgYnJk
> IGZmOmZmOmZmOmZmOmZmOmZmCiAgICBpbmV0IDE5Mi4xNjguMTIyLjEzLzI0
> IGJyZCAxOTIuMTY4LjEyMi4yNTUgc2NvcGUgZ2xvYmFsIGR5bmFtaWMgZXRoMA
> ogICAgICAgdmFsaWRfbGZ0IDMwNjRzZWMgcHJlZmVycmVkX2xmdCAzMDY0c2Vj
> CiAgICBpbmV0NiBmZTgwOjo1MDU0OmZmOmZlMTI6MzQwMy82NCBzY29wZSB
> saW5rIAogICAgICAgdmFsaWRfbGZ0IGZvcmV2ZXIgcHJlZmVycmVkX2xmdCBmb3J
> ldmVyCg==", "exited": true}} ^C address@hidden:~$ cat <<EOF | base64 -d
[Robert Hoo]
[trim...]
[Robert Hoo]
Thanks Michael, this example is helpful. I'll have a try then.
1 more question: is qemu-ga-client actively maintained? will it be updated to
support more
guest agent commands?
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
> state UP group default qlen 1000
> link/ether 52:54:00:12:34:03 brd ff:ff:ff:ff:ff:ff
> inet 192.168.122.13/24 brd 192.168.122.255 scope global dynamic eth0
> valid_lft 3064sec preferred_lft 3064sec
> inet6 fe80::5054:ff:fe12:3403/64 scope link
> valid_lft forever preferred_lft forever
>
>
> >
> > Best Regards,
> > Robert Hoo
> >
> >