[pve-devel] [PATCH] enable virtio-scsi iothread hot-unplug for qemu 2.7 v2

Alexandre Derumier aderumier at odiso.com
Thu Oct 13 11:41:02 CEST 2016


changelog: add a check on current kvm binary version

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0c6d604..05edd7a 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3516,9 +3516,11 @@ sub vm_deviceunplug {
 
     } elsif ($deviceid =~ m/^(scsi)(\d+)$/) {
 
-	#qemu 2.3 segfault on drive_del with virtioscsi + iothread
-	my $device = parse_drive($deviceid, $conf->{$deviceid});
-	die "virtioscsi with iothread is not hot-unplugglable currently" if $device->{iothread};
+	my $kvmver = kvm_user_version();
+	if (!qemu_machine_feature_enabled (undef, $kvmver, 2, 7)) {
+	    my $device = parse_drive($deviceid, $conf->{$deviceid});
+	    die "virtioscsi with iothread is hot-unplugglable since qemu 2.7" if $device->{iothread};
+	}
 
         qemu_devicedel($vmid, $deviceid);
         qemu_drivedel($vmid, $deviceid);
@@ -3564,7 +3566,10 @@ sub qemu_iothread_add {
 sub qemu_iothread_del {
     my($conf, $vmid, $deviceid) = @_;
 
-    my $device = parse_drive($deviceid, $conf->{$deviceid});
+    my $drive = $deviceid;
+    $drive =~ s/virtioscsi/scsi/;
+    my $device = parse_drive($drive, $conf->{$drive});
+
     if ($device->{iothread}) {
 	my $iothreads = vm_iothreads_list($vmid);
 	qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"};
-- 
2.1.4




More information about the pve-devel mailing list