qemu: process: Fix and improve disk data extraction
Extract information for all disks and update tray state and source only for removable drives. Additionally store whether a drive is removable and whether it has a tray.
This commit is contained in:
parent
d9bee413ad
commit
894dc85fd1
@ -299,6 +299,10 @@ struct _qemuDomainDiskPrivate {
|
|||||||
/* for storage devices using auth/secret
|
/* for storage devices using auth/secret
|
||||||
* NB: *not* to be written to qemu domain object XML */
|
* NB: *not* to be written to qemu domain object XML */
|
||||||
qemuDomainSecretInfoPtr secinfo;
|
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) \
|
# define QEMU_DOMAIN_HOSTDEV_PRIVATE(hostdev) \
|
||||||
|
@ -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:
|
* qemuMonitorGetAllBlockStatsInfo:
|
||||||
* @mon: monitor object
|
* @mon: monitor object
|
||||||
|
@ -404,9 +404,6 @@ int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
int qemuMonitorBlockIOStatusToError(const char *status);
|
int qemuMonitorBlockIOStatusToError(const char *status);
|
||||||
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);
|
virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon);
|
||||||
struct qemuDomainDiskInfo *
|
|
||||||
qemuMonitorBlockInfoLookup(virHashTablePtr blockInfo,
|
|
||||||
const char *dev_name);
|
|
||||||
|
|
||||||
typedef struct _qemuBlockStats qemuBlockStats;
|
typedef struct _qemuBlockStats qemuBlockStats;
|
||||||
typedef qemuBlockStats *qemuBlockStatsPtr;
|
typedef qemuBlockStats *qemuBlockStatsPtr;
|
||||||
|
@ -6254,25 +6254,27 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
for (i = 0; i < vm->def->ndisks; i++) {
|
for (i = 0; i < vm->def->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk = vm->def->disks[i];
|
virDomainDiskDefPtr disk = vm->def->disks[i];
|
||||||
|
qemuDomainDiskPrivatePtr diskpriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
struct qemuDomainDiskInfo *info;
|
struct qemuDomainDiskInfo *info;
|
||||||
|
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
|
if (!(info = virHashLookup(table, disk->info.alias)))
|
||||||
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
info = qemuMonitorBlockInfoLookup(table, disk->info.alias);
|
if (info->removable) {
|
||||||
if (!info)
|
if (info->empty)
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (info->tray_open) {
|
|
||||||
if (virDomainDiskGetSource(disk))
|
|
||||||
ignore_value(virDomainDiskSetSource(disk, NULL));
|
ignore_value(virDomainDiskSetSource(disk, NULL));
|
||||||
|
|
||||||
disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
|
if (info->tray) {
|
||||||
} else {
|
if (info->tray_open)
|
||||||
disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
|
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;
|
ret = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user