blockdev: introduce qdev_id_to_drive_id() helper
To be re-used by users of the query-block QMP command. With -blockdev,
the 'device' property is not initialized. See also commit 9af3ef69
("vm devices list: prepare querying block device names for -blockdev")
for context.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
439f6e2a1d
commit
fb7d2c5509
2 changed files with 17 additions and 8 deletions
|
|
@ -55,6 +55,7 @@ use PVE::QemuConfig;
|
|||
use PVE::QemuConfig::NoWrite;
|
||||
use PVE::QemuMigrate::Helpers;
|
||||
use PVE::QemuServer::Agent qw(qga_check_running);
|
||||
use PVE::QemuServer::Blockdev;
|
||||
use PVE::QemuServer::BlockJob;
|
||||
use PVE::QemuServer::Helpers
|
||||
qw(config_aware_timeout get_iscsi_initiator_name min_version kvm_user_version windows_version);
|
||||
|
|
@ -3813,14 +3814,8 @@ sub vm_devices_list {
|
|||
my $resblock = mon_cmd($vmid, 'query-block');
|
||||
for my $block ($resblock->@*) {
|
||||
my $qdev_id = $block->{qdev} or next;
|
||||
if ($qdev_id =~ m|^/machine/peripheral/(virtio(\d+))/virtio-backend$|) {
|
||||
$qdev_id = $1;
|
||||
} elsif ($qdev_id =~ m|^/machine/system\.flash0$|) {
|
||||
$qdev_id = 'pflash0';
|
||||
} elsif ($qdev_id =~ m|^/machine/system\.flash1$|) {
|
||||
$qdev_id = 'efidisk0';
|
||||
}
|
||||
$devices->{$qdev_id} = 1;
|
||||
my $drive_id = PVE::QemuServer::Blockdev::qdev_id_to_drive_id($qdev_id);
|
||||
$devices->{$drive_id} = 1;
|
||||
}
|
||||
|
||||
my $resmice = mon_cmd($vmid, 'query-mice');
|
||||
|
|
|
|||
|
|
@ -44,6 +44,20 @@ my sub is_fleecing_top_node {
|
|||
return $node_name =~ m/-fleecing$/ ? 1 : 0;
|
||||
}
|
||||
|
||||
sub qdev_id_to_drive_id {
|
||||
my ($qdev_id) = @_;
|
||||
|
||||
if ($qdev_id =~ m|^/machine/peripheral/(virtio(\d+))/virtio-backend$|) {
|
||||
return $1;
|
||||
} elsif ($qdev_id =~ m|^/machine/system\.flash0$|) {
|
||||
return 'pflash0';
|
||||
} elsif ($qdev_id =~ m|^/machine/system\.flash1$|) {
|
||||
return 'efidisk0';
|
||||
}
|
||||
|
||||
return $qdev_id; # for SCSI/SATA/IDE it's the same
|
||||
}
|
||||
|
||||
my sub get_node_name {
|
||||
my ($type, $drive_id, $volid, $options) = @_;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue