mirror of https://gitee.com/openkylin/libvirt.git
vz: check supported disk format and bus
Now we check disk parameters correctness in DomainPostParse. Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
This commit is contained in:
parent
19d979edff
commit
adbe76fb42
|
@ -175,8 +175,11 @@ static int
|
|||
vzDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
virCapsPtr caps ATTRIBUTE_UNUSED,
|
||||
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
||||
void *opaque ATTRIBUTE_UNUSED)
|
||||
void *opaque)
|
||||
{
|
||||
if (vzCheckUnsupportedDisks(def, opaque) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -239,6 +242,7 @@ vzOpenDefault(virConnectPtr conn)
|
|||
if (!(privconn->caps = vzBuildCapabilities()))
|
||||
goto error;
|
||||
|
||||
vzDomainDefParserConfig.priv = &privconn->vzCaps;
|
||||
if (!(privconn->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig,
|
||||
NULL, NULL)))
|
||||
goto error;
|
||||
|
|
|
@ -3137,30 +3137,10 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
|
|||
pret = PrlVmDev_SetConnected(sdkdisk, 1);
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
|
||||
virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_PLOOP) {
|
||||
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format of "
|
||||
"disk %s, vz driver supports only "
|
||||
"images in ploop format."), disk->src->path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_FILE)
|
||||
emutype = PDT_USE_IMAGE_FILE;
|
||||
} else {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
|
||||
(virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_RAW &&
|
||||
virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_NONE &&
|
||||
virDomainDiskGetFormat(disk) != VIR_STORAGE_FILE_AUTO)) {
|
||||
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Invalid format "
|
||||
"of disk %s, it should be either not set, or set "
|
||||
"to raw or auto."), disk->src->path);
|
||||
goto cleanup;
|
||||
}
|
||||
else
|
||||
emutype = PDT_USE_REAL_DEVICE;
|
||||
}
|
||||
|
||||
pret = PrlVmDev_SetEmulatedType(sdkdisk, emutype);
|
||||
prlsdkCheckRetGoto(pret, cleanup);
|
||||
|
|
|
@ -249,3 +249,53 @@ vzInitVersion(vzConnPtr privconn)
|
|||
VIR_FREE(output);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
vzCheckUnsupportedDisks(virDomainDefPtr def, vzCapabilitiesPtr vzCaps)
|
||||
{
|
||||
size_t i, j;
|
||||
virDomainDiskDefPtr disk;
|
||||
virStorageFileFormat diskFormat;
|
||||
bool supported;
|
||||
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
disk = def->disks[i];
|
||||
diskFormat = virDomainDiskGetFormat(disk);
|
||||
supported = true;
|
||||
if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
|
||||
diskFormat != VIR_STORAGE_FILE_NONE) {
|
||||
|
||||
if (IS_CT(def))
|
||||
supported = vzCaps->ctDiskFormat == diskFormat;
|
||||
else
|
||||
supported = vzCaps->vmDiskFormat == diskFormat;
|
||||
}
|
||||
} else {
|
||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
||||
supported = diskFormat == VIR_STORAGE_FILE_RAW ||
|
||||
diskFormat == VIR_STORAGE_FILE_NONE ||
|
||||
diskFormat == VIR_STORAGE_FILE_AUTO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!supported) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported format of disk %s"),
|
||||
disk->src->path);
|
||||
return -1;
|
||||
}
|
||||
for (j = 0; vzCaps->diskBuses[j] != VIR_DOMAIN_DISK_BUS_LAST; j++) {
|
||||
if (disk->bus == vzCaps->diskBuses[j])
|
||||
break;
|
||||
}
|
||||
|
||||
if (vzCaps->diskBuses[j] == VIR_DOMAIN_DISK_BUS_LAST) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported disk bus type %s"),
|
||||
virDomainDiskBusTypeToString(disk->bus));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,9 @@ vzNewDomain(vzConnPtr privconn,
|
|||
const unsigned char *uuid);
|
||||
int
|
||||
vzInitVersion(vzConnPtr privconn);
|
||||
int
|
||||
vzCheckUnsupportedDisks(virDomainDefPtr def,
|
||||
vzCapabilitiesPtr vzCaps);
|
||||
|
||||
# define PARALLELS_BLOCK_STATS_FOREACH(OP) \
|
||||
OP(rd_req, VIR_DOMAIN_BLOCK_STATS_READ_REQ, "read_requests") \
|
||||
|
|
Loading…
Reference in New Issue