From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 387271FF17E for ; Thu, 2 Oct 2025 15:21:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 98C2810829; Thu, 2 Oct 2025 15:21:28 +0200 (CEST) Message-ID: Date: Thu, 2 Oct 2025 15:20:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox VE development discussion References: <20250822141803.1658181-1-alexandre.derumier@groupe-cyllene.com> Content-Language: en-US From: Fiona Ebner In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1759411231021 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.023 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v3 qemu-server 06/10] convert drive device to json format X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Am 22.08.25 um 4:18 PM schrieb Alexandre Derumier via pve-devel: > @@ -52,14 +52,18 @@ sub print_drivedevice_full { > > my $drive_id = PVE::QemuServer::Drive::get_drive_id($drive); > if ($drive->{interface} eq 'virtio') { > - my $pciaddr = print_pci_addr("$drive_id", $bridges, $arch); > - $device = 'virtio-blk-pci'; > + my $pciaddr = get_pci_addr("$drive_id", $bridges, $arch); > + $device = { > + id => $drive_id, > + driver => 'virtio-blk-pci', > + bus => $pciaddr->{bus}, > + addr => $pciaddr->{addr}, Doesn't the value need to be a coerced into a string? # kvm -device virtio-blk-pci,help | grep addr addr= ... > + }; > # for the switch to -blockdev, there is no blockdev for 'none' > if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { > - $device .= ",drive=drive-$drive_id"; > + $device->{drive} = "drive-$drive_id"; > } > - $device .= ",id=${drive_id}${pciaddr}"; > - $device .= ",iothread=iothread-$drive_id" if $drive->{iothread}; > + $device->{iothread} = "iothread-$drive_id" if $drive->{iothread}; > } elsif ($drive->{interface} eq 'scsi') { > > my ($maxdev, $controller, $controller_prefix) = scsihw_infos($conf, $drive); > @@ -68,39 +72,44 @@ sub print_drivedevice_full { > my $device_type = > PVE::QemuServer::Drive::get_scsi_device_type($drive, $storecfg, $machine_version); > > + $device = { > + id => $drive_id, > + driver => "scsi-$device_type", > + bus => "$controller_prefix$controller.0", > + }; > + > if (!$conf->{scsihw} || $conf->{scsihw} =~ m/^lsi/ || $conf->{scsihw} eq 'pvscsi') { > - $device = "scsi-$device_type,bus=$controller_prefix$controller.0,scsi-id=$unit"; > + $device->{'scsi-id'} = $unit; Please coerce into an int, just to be sure > } else { > - $device = "scsi-$device_type,bus=$controller_prefix$controller.0,channel=0,scsi-id=0" > - . ",lun=$drive->{index}"; > + $device->{'scsi-id'} = 0; > + $device->{channel} = 0; > + $device->{lun} = int($drive->{index}); > } > # for the switch to -blockdev, there is no blockdev for 'none' > if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { > - $device .= ",drive=drive-$drive_id"; > + $device->{drive} = "drive-$drive_id"; > } > - $device .= ",id=$drive_id"; > > # For the switch to -blockdev, the SCSI device ID needs to be explicitly specified. Note > # that only ide-cd and ide-hd have a 'device_id' option. > if ( > min_version($machine_version, 10, 0) && ($device_type eq 'cd' || $device_type eq 'hd') > ) { > - $device .= ",device_id=drive-${drive_id}"; > + $device->{'device_id'} = "drive-${drive_id}"; > } > > if ($drive->{ssd} && ($device_type eq 'block' || $device_type eq 'hd')) { > - $device .= ",rotation_rate=1"; > + $device->{'rotation_rate'} = 1; > } > - $device .= ",wwn=$drive->{wwn}" if $drive->{wwn}; > - > + $device->{wwn} = $drive->{wwn} if $drive->{wwn}; Needs to be coerced to int (we have string in our schema) # kvm -device scsi-hd,help | grep wwn port_wwn= - (default: 0) wwn= - (default: 0) > # only scsi-hd and scsi-cd support passing vendor and product information and have a > # 'write-cache' option > if ($device_type eq 'hd' || $device_type eq 'cd') { > if (my $vendor = $drive->{vendor}) { > - $device .= ",vendor=$vendor"; > + $device->{vendor} = $vendor; Please coerce into a string by surrounding with "" > } > if (my $product = $drive->{product}) { > - $device .= ",product=$product"; > + $device->{product} = $product; Please coerce into a string by surrounding with "" > } > > $has_write_cache = 1; > @@ -134,27 +143,26 @@ sub print_drivedevice_full { > # backup if the type is 'ide-cd' instead. > $device_type = 'cd' if $conf->{template}; > > - $device = "ide-$device_type"; > + $device = { id => $drive_id, driver => "ide-$device_type" }; > if ($drive->{interface} eq 'ide') { > - $device .= ",bus=ide.$controller,unit=$unit"; > + $device->{bus} = "ide.$controller"; > + $device->{unit} = $unit; Please coerce into an int, just to be sure > } else { > - $device .= ",bus=ahci$controller.$unit"; > + $device->{bus} = "ahci$controller.$unit"; > } > if (!min_version($machine_version, 10, 0) || $drive->{file} ne 'none') { > - $device .= ",drive=drive-$drive_id"; > + $device->{drive} = "drive-$drive_id"; > } > - $device .= ",id=$drive_id"; > > if ($device_type eq 'hd') { > if (my $model = $drive->{model}) { > - $model = URI::Escape::uri_unescape($model); > - $device .= ",model=$model"; > + $device->{model} = URI::Escape::uri_unescape($model); > } > if ($drive->{ssd}) { > - $device .= ",rotation_rate=1"; > + $device->{'rotation_rate'} = 1; > } > } > - $device .= ",wwn=$drive->{wwn}" if $drive->{wwn}; > + $device->{wwn} = $drive->{wwn} if $drive->{wwn}; Needs to be coerced to int (we have string in our schema) [I] root@pve9a1 ~# kvm -device ide-hd,help | grep wwn wwn= - (default: 0) > } elsif ($drive->{interface} eq 'usb') { > die "implement me"; > # -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 > @@ -162,11 +170,10 @@ sub print_drivedevice_full { > die "unsupported interface type"; > } > > - $device .= ",bootindex=$drive->{bootindex}" if $drive->{bootindex}; > + $device->{bootindex} = $drive->{bootindex} if $drive->{bootindex}; Please coerce into an int, just to be sure > > if (my $serial = $drive->{serial}) { > - $serial = URI::Escape::uri_unescape($serial); > - $device .= ",serial=$serial"; > + $device->{serial} = URI::Escape::uri_unescape($serial); > } > > if (min_version($machine_version, 10, 0)) { # for the switch to -blockdev > @@ -175,10 +182,10 @@ sub print_drivedevice_full { > if (my $cache = $drive->{cache}) { > $write_cache = 'off' if $cache eq 'writethrough' || $cache eq 'directsync'; > } > - $device .= ",write-cache=$write_cache"; > + $device->{'write-cache'} = $write_cache; > } > for my $o (qw(rerror werror)) { > - $device .= ",$o=$drive->{$o}" if defined($drive->{$o}); > + $device->{$o} = $drive->{$o} if defined($drive->{$o}); > } > } > > -- > 2.47.2 > > _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel