mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
src/xenxs: Refactor code formating xm disk config
introduce function xenFormatXMDisks(virConfPtr conf,.........); which formats domain disks config instead Signed-off-by: Kiarie Kahurani <davidkiarie4@gmail.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
5dde1629fb
commit
f8ad0198a1
@ -1897,6 +1897,51 @@ xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
||||||
|
{
|
||||||
|
virConfValuePtr diskVal = NULL;
|
||||||
|
size_t i = 0;
|
||||||
|
int hvm = STREQ(def->os.type, "hvm");
|
||||||
|
|
||||||
|
if (VIR_ALLOC(diskVal) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
diskVal->type = VIR_CONF_LIST;
|
||||||
|
diskVal->list = NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
|
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
|
||||||
|
def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
||||||
|
def->disks[i]->dst &&
|
||||||
|
STREQ(def->disks[i]->dst, "hdc")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (xenFormatXMDisk(diskVal, def->disks[i],
|
||||||
|
hvm, xendConfigVersion) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diskVal->list != NULL) {
|
||||||
|
int ret = virConfSetValue(conf, "disk", diskVal);
|
||||||
|
diskVal = NULL;
|
||||||
|
if (ret < 0)
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
VIR_FREE(diskVal);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virConfFreeValue(diskVal);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
|
||||||
either 32, or 64 on a platform where long is big enough. */
|
either 32, or 64 on a platform where long is big enough. */
|
||||||
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
|
verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
|
||||||
@ -1910,7 +1955,6 @@ xenFormatXM(virConnectPtr conn,
|
|||||||
int hvm = 0;
|
int hvm = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *cpus = NULL;
|
char *cpus = NULL;
|
||||||
virConfValuePtr diskVal = NULL;
|
|
||||||
virConfValuePtr netVal = NULL;
|
virConfValuePtr netVal = NULL;
|
||||||
|
|
||||||
if (!(conf = virConfNew()))
|
if (!(conf = virConfNew()))
|
||||||
@ -2178,33 +2222,8 @@ xenFormatXM(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* analyze of the devices */
|
if (xenFormatXMDisks(conf, def, xendConfigVersion) < 0)
|
||||||
if (VIR_ALLOC(diskVal) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
diskVal->type = VIR_CONF_LIST;
|
|
||||||
diskVal->list = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
|
||||||
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
|
|
||||||
def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
|
||||||
def->disks[i]->dst &&
|
|
||||||
STREQ(def->disks[i]->dst, "hdc")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (xenFormatXMDisk(diskVal, def->disks[i],
|
|
||||||
hvm, xendConfigVersion) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
if (diskVal->list != NULL) {
|
|
||||||
int ret = virConfSetValue(conf, "disk", diskVal);
|
|
||||||
diskVal = NULL;
|
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
VIR_FREE(diskVal);
|
|
||||||
|
|
||||||
if (VIR_ALLOC(netVal) < 0)
|
if (VIR_ALLOC(netVal) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2248,7 +2267,6 @@ xenFormatXM(virConnectPtr conn,
|
|||||||
return conf;
|
return conf;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virConfFreeValue(diskVal);
|
|
||||||
virConfFreeValue(netVal);
|
virConfFreeValue(netVal);
|
||||||
VIR_FREE(cpus);
|
VIR_FREE(cpus);
|
||||||
if (conf)
|
if (conf)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user