mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
Introduce and use virDomainDiskEmptySource
Currently, if we want to zero out disk source (e,g, due to startupPolicy when starting up a domain) we use virDomainDiskSetSource(disk, NULL). This works well for file based storage (storage type file, dir, or block). But it doesn't work at all for other types like volume and network. So imagine that you have a domain that has a CDROM configured which source is a volume from an inactive pool. Because it is startupPolicy='optional', the CDROM is empty when the domain starts. However, the source element is not cleared out in the status XML and thus when the daemon restarts and tries to reconnect to the domain it refreshes the disks (which fails - the storage pool is still not running) and thus the domain is killed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c3a83bad2a
commit
462c4b66fa
@ -1719,6 +1719,16 @@ virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virDomainDiskEmptySource(virDomainDiskDefPtr def)
|
||||
{
|
||||
virStorageSourcePtr src = def->src;
|
||||
|
||||
virStorageSourceClear(src);
|
||||
src->type = VIR_STORAGE_TYPE_FILE;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
virDomainDiskGetDriver(virDomainDiskDefPtr def)
|
||||
{
|
||||
|
@ -2590,6 +2590,7 @@ void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
|
||||
const char *virDomainDiskGetSource(virDomainDiskDef const *def);
|
||||
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
void virDomainDiskEmptySource(virDomainDiskDefPtr def);
|
||||
const char *virDomainDiskGetDriver(virDomainDiskDefPtr def);
|
||||
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
|
||||
ATTRIBUTE_RETURN_CHECK;
|
||||
|
@ -299,6 +299,7 @@ virDomainDiskDetectZeroesTypeFromString;
|
||||
virDomainDiskDetectZeroesTypeToString;
|
||||
virDomainDiskDeviceTypeToString;
|
||||
virDomainDiskDiscardTypeToString;
|
||||
virDomainDiskEmptySource;
|
||||
virDomainDiskErrorPolicyTypeFromString;
|
||||
virDomainDiskErrorPolicyTypeToString;
|
||||
virDomainDiskFindByBusAndDst;
|
||||
|
@ -4908,7 +4908,7 @@ qemuDomainCheckRemoveOptionalDisk(virQEMUDriverPtr driver,
|
||||
event = virDomainEventDiskChangeNewFromObj(vm, src, NULL,
|
||||
disk->info.alias,
|
||||
VIR_DOMAIN_EVENT_DISK_CHANGE_MISSING_ON_START);
|
||||
ignore_value(virDomainDiskSetSource(disk, NULL));
|
||||
virDomainDiskEmptySource(disk);
|
||||
/* keeping the old startup policy would be invalid for new images */
|
||||
disk->startupPolicy = VIR_DOMAIN_STARTUP_POLICY_DEFAULT;
|
||||
} else {
|
||||
|
@ -6804,7 +6804,7 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver,
|
||||
|
||||
if (info->removable) {
|
||||
if (info->empty)
|
||||
ignore_value(virDomainDiskSetSource(disk, NULL));
|
||||
virDomainDiskEmptySource(disk);
|
||||
|
||||
if (info->tray) {
|
||||
if (info->tray_open)
|
||||
|
Loading…
Reference in New Issue
Block a user