mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Adapt to VIR_ALLOC and virAsprintf in src/vmx/*
This commit is contained in:
parent
b24656bcc5
commit
ed11a1a43e
@ -553,10 +553,8 @@ virVMXEscapeHex(const char *string, char escape, const char *special)
|
|||||||
++length;
|
++length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(escaped, length) < 0) {
|
if (VIR_ALLOC_N(escaped, length) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
tmp1 = string; /* reading from this one */
|
tmp1 = string; /* reading from this one */
|
||||||
tmp2 = escaped; /* writing to this one */
|
tmp2 = escaped; /* writing to this one */
|
||||||
@ -1121,10 +1119,8 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def,
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int *autodetectedModels;
|
int *autodetectedModels;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(autodetectedModels, def->ndisks) < 0) {
|
if (VIR_ALLOC_N(autodetectedModels, def->ndisks) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < def->ncontrollers; ++i) {
|
for (i = 0; i < def->ncontrollers; ++i) {
|
||||||
controller = def->controllers[i];
|
controller = def->controllers[i];
|
||||||
@ -1287,10 +1283,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate domain def */
|
/* Allocate domain def */
|
||||||
if (VIR_ALLOC(def) < 0) {
|
if (VIR_ALLOC(def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->virtType = VIR_DOMAIN_VIRT_VMWARE;
|
def->virtType = VIR_DOMAIN_VIRT_VMWARE;
|
||||||
def->id = -1;
|
def->id = -1;
|
||||||
@ -1432,10 +1426,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
cpumasklen = 0;
|
cpumasklen = 0;
|
||||||
|
|
||||||
def->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
|
def->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
|
||||||
if (!def->cpumask) {
|
if (!def->cpumask)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
while (*current != '\0') {
|
while (*current != '\0') {
|
||||||
virSkipSpaces(¤t);
|
virSkipSpaces(¤t);
|
||||||
@ -1551,10 +1543,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
||||||
/* def:graphics */
|
/* def:graphics */
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0) {
|
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->ngraphics = 0;
|
def->ngraphics = 0;
|
||||||
|
|
||||||
@ -1567,10 +1557,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy = 66 */
|
/* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy = 66 */
|
||||||
if (VIR_ALLOC_N(def->disks, 66) < 0) {
|
if (VIR_ALLOC_N(def->disks, 66) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->ndisks = 0;
|
def->ndisks = 0;
|
||||||
|
|
||||||
@ -1692,10 +1680,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
if (sharedFolder_maxNum > 0) {
|
if (sharedFolder_maxNum > 0) {
|
||||||
int number;
|
int number;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->fss, sharedFolder_maxNum) < 0) {
|
if (VIR_ALLOC_N(def->fss, sharedFolder_maxNum) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->nfss = 0;
|
def->nfss = 0;
|
||||||
|
|
||||||
@ -1713,10 +1699,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* def:nets */
|
/* def:nets */
|
||||||
if (VIR_ALLOC_N(def->nets, 4) < 0) {
|
if (VIR_ALLOC_N(def->nets, 4) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->nnets = 0;
|
def->nnets = 0;
|
||||||
|
|
||||||
@ -1735,10 +1719,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
||||||
/* def:videos */
|
/* def:videos */
|
||||||
if (VIR_ALLOC_N(def->videos, 1) < 0) {
|
if (VIR_ALLOC_N(def->videos, 1) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->nvideos = 0;
|
def->nvideos = 0;
|
||||||
|
|
||||||
@ -1755,10 +1737,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
/* FIXME */
|
/* FIXME */
|
||||||
|
|
||||||
/* def:serials */
|
/* def:serials */
|
||||||
if (VIR_ALLOC_N(def->serials, 4) < 0) {
|
if (VIR_ALLOC_N(def->serials, 4) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->nserials = 0;
|
def->nserials = 0;
|
||||||
|
|
||||||
@ -1774,10 +1754,8 @@ virVMXParseConfig(virVMXContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* def:parallels */
|
/* def:parallels */
|
||||||
if (VIR_ALLOC_N(def->parallels, 3) < 0) {
|
if (VIR_ALLOC_N(def->parallels, 3) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def->nparallels = 0;
|
def->nparallels = 0;
|
||||||
|
|
||||||
@ -1832,10 +1810,8 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
(*def)->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
||||||
|
|
||||||
@ -2006,10 +1982,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->device = device;
|
(*def)->device = device;
|
||||||
(*def)->bus = busType;
|
(*def)->bus = busType;
|
||||||
@ -2032,10 +2006,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virAsprintf(&prefix, "scsi%d:%d", controllerOrBus, unit) < 0) {
|
if (virAsprintf(&prefix, "scsi%d:%d", controllerOrBus, unit) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->dst =
|
(*def)->dst =
|
||||||
virIndexToDiskName
|
virIndexToDiskName
|
||||||
@ -2058,10 +2030,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virAsprintf(&prefix, "ide%d:%d", controllerOrBus, unit) < 0) {
|
if (virAsprintf(&prefix, "ide%d:%d", controllerOrBus, unit) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->dst = virIndexToDiskName(controllerOrBus * 2 + unit, "hd");
|
(*def)->dst = virIndexToDiskName(controllerOrBus * 2 + unit, "hd");
|
||||||
|
|
||||||
@ -2091,10 +2061,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virAsprintf(&prefix, "floppy%d", unit) < 0) {
|
if (virAsprintf(&prefix, "floppy%d", unit) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->dst = virIndexToDiskName(unit, "fd");
|
(*def)->dst = virIndexToDiskName(unit, "fd");
|
||||||
|
|
||||||
@ -2347,10 +2315,8 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->type = VIR_DOMAIN_FS_TYPE_MOUNT;
|
(*def)->type = VIR_DOMAIN_FS_TYPE_MOUNT;
|
||||||
|
|
||||||
@ -2472,10 +2438,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
||||||
|
|
||||||
@ -2691,10 +2655,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
||||||
|
|
||||||
@ -2782,10 +2744,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virAsprintf(&(*def)->source.data.tcp.service, "%d",
|
if (virAsprintf(&(*def)->source.data.tcp.service, "%d",
|
||||||
parsedUri->port) < 0) {
|
parsedUri->port) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* See vSphere API documentation about VirtualSerialPortURIBackingInfo */
|
/* See vSphere API documentation about VirtualSerialPortURIBackingInfo */
|
||||||
if (parsedUri->scheme == NULL ||
|
if (parsedUri->scheme == NULL ||
|
||||||
@ -2884,10 +2844,8 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
(*def)->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
||||||
|
|
||||||
@ -2982,10 +2940,8 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(*def) < 0) {
|
if (VIR_ALLOC(*def) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
(*def)->type = VIR_DOMAIN_VIDEO_TYPE_VMVGA;
|
(*def)->type = VIR_DOMAIN_VIDEO_TYPE_VMVGA;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user