[pve-devel] [PATCH qemu-server 1/1] Add 'type' to agent_fmt

Matt Dunwoodie ncon at noconroy.net
Mon Nov 18 07:46:12 CET 2019


This adds an extra field to agent_fmt that specifes the type of guest
agent connection to use. Currently there is no choice, and defaults to
virtio-serial. Since qemu-ga also runs over isa-serial, this allows OSes
such as NetBSD and OpenBSD, which do not have support for virtio-serial,
to run a qemu-ga.

This is an optional field, which leaves the default as virtio-serial. As
it doesn't change the default, it will require no change to older
configuration files.

Signed-off-by: Matt Dunwoodie <ncon at noconroy.net>
---
 PVE/QemuServer.pm | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index bfe6662..b1f47a1 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -251,6 +251,13 @@ my $agent_fmt = {
 	optional => 1,
 	default => 0
     },
+    type => {
+	description => "Select the agent type",
+	type => 'string',
+	default => 'virtio',
+	optional => 1,
+	enum => [qw(virtio isa)],
+    },
 };
 
 my $vga_fmt = {
@@ -3904,12 +3911,19 @@ sub config_to_command {
 
     push @$cmd, '-k', $conf->{keyboard} if defined($conf->{keyboard});
 
-    if (parse_guest_agent($conf)->{enabled}) {
+    my $guest_agent = parse_guest_agent($conf);
+
+    if ($guest_agent->{enabled}) {
 	my $qgasocket = qmp_socket($vmid, 1);
-	my $pciaddr = print_pci_addr("qga0", $bridges, $arch, $machine_type);
 	push @$devices, '-chardev', "socket,path=$qgasocket,server,nowait,id=qga0";
-	push @$devices, '-device', "virtio-serial,id=qga0$pciaddr";
-	push @$devices, '-device', 'virtserialport,chardev=qga0,name=org.qemu.guest_agent.0';
+
+	if ($guest_agent->{type} eq 'virtio') {
+	    my $pciaddr = print_pci_addr("qga0", $bridges, $arch, $machine_type);
+	    push @$devices, '-device', "virtio-serial,id=qga0$pciaddr";
+	    push @$devices, '-device', 'virtserialport,chardev=qga0,name=org.qemu.guest_agent.0';
+	} elsif ($guest_agent->{type} eq 'isa') {
+	    push @$devices, '-device', "isa-serial,chardev=qga0";
+	}
     }
 
     my $spice_port;
-- 
2.23.0




More information about the pve-devel mailing list