|
|
696189 |
From 0699afed37343d73c6803cabec466e1c3ca229b0 Mon Sep 17 00:00:00 2001
|
|
|
696189 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
696189 |
Date: Mon, 13 Jun 2022 19:01:32 +0200
|
|
|
696189 |
Subject: [PATCH] output/create_libvirt_xml: wire up the QEMU guest agent
|
|
|
696189 |
|
|
|
696189 |
The intent (even before RHBZ#2028764) has been to install the QEMU guest
|
|
|
696189 |
agent in the converted domain unconditionally. Therefore, in order for the
|
|
|
696189 |
GA to be actually accessible from the host side, augment the libvirt
|
|
|
696189 |
output module with a "guest agent connection" also unconditionally.
|
|
|
696189 |
|
|
|
696189 |
For starters, the domain needs a virtio-serial device. Then there must be
|
|
|
696189 |
a port on the device that (in the guest) the GA identifies by name, and
|
|
|
696189 |
that (on the host) is exposed as a listening socket (usually in the unix
|
|
|
696189 |
address family). The adress of that port (usually a pathname, i.e., for a
|
|
|
696189 |
unix domain socket) is then passed to whatever host-side application wants
|
|
|
696189 |
to talk to the GA.
|
|
|
696189 |
|
|
|
696189 |
The minimal domain XML fragment for that ("minimal" for our purposes) is
|
|
|
696189 |
|
|
|
696189 |
<controller type='virtio-serial' model='virtio'>
|
|
|
696189 |
<channel type='unix'>
|
|
|
696189 |
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
|
|
696189 |
</channel>
|
|
|
696189 |
|
|
|
696189 |
The "controller" element is needed because "controller/@model" is where we
|
|
|
696189 |
regulate "virtio" vs. "virtio-transitional".
|
|
|
696189 |
|
|
|
696189 |
Everything else is filled in by libvirt. Notably, libvirt (a) creates and
|
|
|
696189 |
binds the unix domain socket itself (usually
|
|
|
696189 |
"/var/lib/libvirt/qemu/channel/target/DOMAIN/org.qemu.guest_agent.0"), (b)
|
|
|
696189 |
passes the file descriptor to QEMU, and (c) figures out the socket
|
|
|
696189 |
pathname for commands such as
|
|
|
696189 |
|
|
|
696189 |
virsh domfsinfo DOMAIN
|
|
|
696189 |
virsh domhostname DOMAIN --source agent
|
|
|
696189 |
virsh domifaddr DOMAIN --source agent
|
|
|
696189 |
virsh guestinfo DOMAIN
|
|
|
696189 |
|
|
|
696189 |
For QEMU, the corresponding options would be
|
|
|
696189 |
|
|
|
696189 |
-chardev socket,id=agent,server=on,wait=off,path=/tmp/DOMAIN-agent \
|
|
|
696189 |
-device virtio-serial-pci,id=vioserial \
|
|
|
696189 |
-device virtserialport,bus=vioserial.0,nr=1,chardev=agent,name=org.qemu.guest_agent.0 \
|
|
|
696189 |
|
|
|
696189 |
Note the "path=/tmp/DOMAIN-agent" property of "-chardev"; virt-v2v would
|
|
|
696189 |
have to generate that (in place of the "fd=nnnn" property that libvirt
|
|
|
696189 |
passes to QEMU).
|
|
|
696189 |
|
|
|
696189 |
Omit extending the QEMU output module for now, as the QGA protocol is
|
|
|
696189 |
based on JSON, and one needs "virsh" or "virt-manager" (or another
|
|
|
696189 |
management application interface) anyway, for efficiently exchanging
|
|
|
696189 |
messages with QGA. I don't know of end-user tools that directly connect to
|
|
|
696189 |
"/tmp/DOMAIN-agent".
|
|
|
696189 |
|
|
|
696189 |
Don't modify the RHV and OpenStack outputs either; both of these
|
|
|
696189 |
management products likely configure the virtio-serial device
|
|
|
696189 |
automatically, for the agent access.
|
|
|
696189 |
|
|
|
696189 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2028764
|
|
|
696189 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
696189 |
Message-Id: <20220613170135.12557-2-lersek@redhat.com>
|
|
|
696189 |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
696189 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
696189 |
(cherry picked from commit 48c6ea27c5a7053e418622f7450e3f9ef05c923f)
|
|
|
696189 |
---
|
|
|
696189 |
output/create_libvirt_xml.ml | 11 +++++++++++
|
|
|
696189 |
tests/test-v2v-i-ova.xml | 4 ++++
|
|
|
696189 |
2 files changed, 15 insertions(+)
|
|
|
696189 |
|
|
|
696189 |
diff --git a/output/create_libvirt_xml.ml b/output/create_libvirt_xml.ml
|
|
|
696189 |
index 68d0a909..531a4f75 100644
|
|
|
696189 |
--- a/output/create_libvirt_xml.ml
|
|
|
696189 |
+++ b/output/create_libvirt_xml.ml
|
|
|
696189 |
@@ -524,6 +524,17 @@ let create_libvirt_xml ?pool source inspect
|
|
|
696189 |
e "console" ["type", "pty"] [];
|
|
|
696189 |
];
|
|
|
696189 |
|
|
|
696189 |
+ (* Given that we install the QEMU Guest Agent for both Linux and Windows
|
|
|
696189 |
+ * guests unconditionally, create the virtio-serial device that's needed for
|
|
|
696189 |
+ * communication between the host and the agent.
|
|
|
696189 |
+ *)
|
|
|
696189 |
+ List.push_back_list devices [
|
|
|
696189 |
+ e "controller" ["type", "virtio-serial"; "model", virtio_model] [];
|
|
|
696189 |
+ e "channel" ["type", "unix"] [
|
|
|
696189 |
+ e "target" ["type", "virtio"; "name", "org.qemu.guest_agent.0"] []
|
|
|
696189 |
+ ]
|
|
|
696189 |
+ ];
|
|
|
696189 |
+
|
|
|
696189 |
List.push_back_list body [
|
|
|
696189 |
e "devices" [] !devices;
|
|
|
696189 |
];
|
|
|
696189 |
diff --git a/tests/test-v2v-i-ova.xml b/tests/test-v2v-i-ova.xml
|
|
|
696189 |
index 6b8cda62..da1db473 100644
|
|
|
696189 |
--- a/tests/test-v2v-i-ova.xml
|
|
|
696189 |
+++ b/tests/test-v2v-i-ova.xml
|
|
|
696189 |
@@ -49,5 +49,9 @@
|
|
|
696189 |
<input type='tablet' bus='usb'/>
|
|
|
696189 |
<input type='mouse' bus='ps2'/>
|
|
|
696189 |
<console type='pty'/>
|
|
|
696189 |
+ <controller type='virtio-serial' model='virtio'/>
|
|
|
696189 |
+ <channel type='unix'>
|
|
|
696189 |
+ <target type='virtio' name='org.qemu.guest_agent.0'/>
|
|
|
696189 |
+ </channel>
|
|
|
696189 |
</devices>
|
|
|
696189 |
</domain>
|