[PATCH qemu-server 4/6] convert iothread to json

Alexandre Derumier alexandre.derumier at groupe-cyllene.com
Fri Jun 27 14:42:26 CEST 2025


Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
---
 src/PVE/QemuServer.pm             | 8 ++++----
 src/PVE/QemuServer/DriveDevice.pm | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm
index 035034ec..6ee156e2 100644
--- a/src/PVE/QemuServer.pm
+++ b/src/PVE/QemuServer.pm
@@ -72,7 +72,7 @@ use PVE::QemuServer::Drive qw(
     print_drive
     storage_allows_io_uring_default
 );
-use PVE::QemuServer::DriveDevice qw(print_drivedevice_controller get_drivedevice print_drivedevice_iothread scsihw_infos);
+use PVE::QemuServer::DriveDevice qw(print_drivedevice_controller get_drivedevice get_drivedevice_iothread scsihw_infos);
 use PVE::QemuServer::Machine;
 use PVE::QemuServer::Memory qw(get_current_memory);
 use PVE::QemuServer::MetaInfo;
@@ -3464,8 +3464,8 @@ sub config_to_command {
 
             $drive->{bootindex} = $bootorder->{$ds} if $bootorder->{$ds};
 
-	    my $iothread = print_drivedevice_iothread($conf, $drive);
-	    push @$cmd, '-object', $iothread if $iothread;
+            my $iothread = get_drivedevice_iothread($conf, $drive);
+            push @$cmd, '-object', to_json($iothread, { canonical => 1 }) if $iothread;
 
             my $controller = print_drivedevice_controller($conf, $drive, $iothread, $scsihw, $arch, $bridges, $used_controller);
             push @$devices, '-device', $controller if $controller;
@@ -3746,7 +3746,7 @@ sub vm_deviceplug {
         }
     } elsif ($deviceid =~ m/^(virtioscsi|scsihw)(\d+)$/) {
         my $scsihw = defined($conf->{scsihw}) ? $conf->{scsihw} : "lsi";
-        my $iothread = print_drivedevice_iothread($conf, $device);
+        my $iothread = get_drivedevice_iothread($conf, $device);
         my $controller = print_drivedevice_controller($conf, $device, $iothread, $scsihw, $arch);
 
         qemu_iothread_add($vmid, $deviceid, $device) if $iothread;
diff --git a/src/PVE/QemuServer/DriveDevice.pm b/src/PVE/QemuServer/DriveDevice.pm
index 103180f3..ab62c4ff 100644
--- a/src/PVE/QemuServer/DriveDevice.pm
+++ b/src/PVE/QemuServer/DriveDevice.pm
@@ -15,7 +15,7 @@ use base qw(Exporter);
 our @EXPORT_OK = qw(
     get_drivedevice
     print_drivedevice_controller
-    print_drivedevice_iothread
+    get_drivedevice_iothread
     scsihw_infos
 );
 
@@ -211,13 +211,13 @@ sub print_drivedevice_controller {
     }
 }
 
-sub print_drivedevice_iothread {
+sub get_drivedevice_iothread {
     my ($conf, $drive) = @_;
 
     my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive);
 
     if ($drive->{interface} eq 'virtio') {
-	return "iothread,id=iothread-$drive_id" if $drive->{iothread};
+	return {'qom-type' => 'iothread', id => "iothread-$drive_id"} if $drive->{iothread};
     }
 
     if ($drive->{interface} eq 'scsi') {
@@ -229,7 +229,7 @@ sub print_drivedevice_iothread {
 	    && $conf->{scsihw} eq "virtio-scsi-single"
 	    && $drive->{iothread}
 	) {
-	    return "iothread,id=iothread-$controller_prefix$controller";
+	    return {'qom-type' => 'iothread', id => "iothread-$controller_prefix$controller"};
 	} elsif ($drive->{iothread}) {
 	    log_warn(
 		"iothread is only valid with virtio disk or virtio-scsi-single controller, ignoring\n"
-- 
2.39.5




More information about the pve-devel mailing list