mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-30 17:45:23 +00:00
conf: Report sensible error for invalid disk name
The error "... but the cause is unknown" appeared for XMLs similar to
this:
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/dev/zero'/>
<target dev='sr0'/>
</disk>
Notice unsupported disk type (for the driver), but also no address
specified. The first part is not a problem and we should not abort
immediately because of that, but the combination with the address
unknown was causing an unspecified error.
While fixing this, I added an error to one place where this return
value was not managed properly.
(cherry picked from commit 03cd6e4ae8
)
This commit is contained in:
parent
adc0bc4c1d
commit
179216680e
@ -2999,8 +2999,12 @@ int
|
|||||||
virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
|
virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
|
||||||
{
|
{
|
||||||
int idx = virDiskNameToIndex(def->dst);
|
int idx = virDiskNameToIndex(def->dst);
|
||||||
if (idx < 0)
|
if (idx < 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("Unknown disk name '%s' and no address specified"),
|
||||||
|
def->dst);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
switch (def->bus) {
|
switch (def->bus) {
|
||||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||||
|
@ -8299,8 +8299,12 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
|
|||||||
!disk->dst)
|
!disk->dst)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virDomainDiskDefAssignAddress(caps, disk) < 0)
|
if (virDomainDiskDefAssignAddress(caps, disk) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Cannot assign address for device name '%s'"),
|
||||||
|
disk->dst);
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
|
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
Loading…
Reference in New Issue
Block a user