diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 825036cb1dd4165b4e2201b87cadedbe79f89a5a..9ac020916ca6410d2cec6e7eb625d4fe9f3540fe 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -299,6 +299,10 @@ struct _qemuDomainDiskPrivate { /* for storage devices using auth/secret * NB: *not* to be written to qemu domain object XML */ qemuDomainSecretInfoPtr secinfo; + + /* information about the device */ + bool tray; /* device has tray */ + bool removable; /* device media can be removed/changed */ }; # define QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev) \ diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 7d1ca91a41b251d15e1bdf81dc75aa13b6400ab0..a0060ccefb12197ff39fabfa53687974c0e6d059 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1826,24 +1826,6 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon) } -struct qemuDomainDiskInfo * -qemuMonitorBlockInfoLookup(virHashTablePtr blockInfo, - const char *dev) -{ - struct qemuDomainDiskInfo *info; - - VIR_DEBUG("blockInfo=%p dev=%s", blockInfo, NULLSTR(dev)); - - if (!(info = virHashLookup(blockInfo, dev))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find info for device '%s'"), - NULLSTR(dev)); - } - - return info; -} - - /** * qemuMonitorGetAllBlockStatsInfo: * @mon: monitor object diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 63593144bd0347c536513c0852446e91d8b3b20a..a1cbc94a6ff8eefe54d7d683d71984a322d272b8 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -404,9 +404,6 @@ int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon, int qemuMonitorBlockIOStatusToError(const char *status); virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon); -struct qemuDomainDiskInfo * -qemuMonitorBlockInfoLookup(virHashTablePtr blockInfo, - const char *dev_name); typedef struct _qemuBlockStats qemuBlockStats; typedef qemuBlockStats *qemuBlockStatsPtr; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f2e284ffe6297272fc9d7c397277889e164a63ee..106ffcda4bbf289663f56d8822b86a1e1a3f1817 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6254,25 +6254,27 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; + qemuDomainDiskPrivatePtr diskpriv = QEMU_DOMAIN_DISK_PRIVATE(disk); struct qemuDomainDiskInfo *info; - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || - disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { - continue; - } - - info = qemuMonitorBlockInfoLookup(table, disk->info.alias); - if (!info) - goto cleanup; + if (!(info = virHashLookup(table, disk->info.alias))) + continue; - if (info->tray_open) { - if (virDomainDiskGetSource(disk)) + if (info->removable) { + if (info->empty) ignore_value(virDomainDiskSetSource(disk, NULL)); - disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN; - } else { - disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; + if (info->tray) { + if (info->tray_open) + disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN; + else + disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; + } } + + /* fill in additional data */ + diskpriv->removable = info->removable; + diskpriv->tray = info->tray; } ret = 0;