mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 22:45:21 +00:00
libxl: prefer g_new0 to VIR_ALLOC
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5df0503d17
commit
97a6a5b145
@ -269,11 +269,9 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpus, nr_nodes) < 0)
|
cpus = g_new0(virCapsHostNUMACellCPUPtr, nr_nodes);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(nr_cpus_node, nr_nodes) < 0)
|
nr_cpus_node = g_new0(int, nr_nodes);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
/* For each node, prepare a list of CPUs belonging to that node */
|
/* For each node, prepare a list of CPUs belonging to that node */
|
||||||
for (i = 0; i < nr_cpus; i++) {
|
for (i = 0; i < nr_cpus; i++) {
|
||||||
@ -285,7 +283,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
|
|||||||
nr_cpus_node[node]++;
|
nr_cpus_node[node]++;
|
||||||
|
|
||||||
if (nr_cpus_node[node] == 1) {
|
if (nr_cpus_node[node] == 1) {
|
||||||
if (VIR_ALLOC(cpus[node]) < 0)
|
cpus[node] = g_new0(virCapsHostNUMACellCPU, 1);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0)
|
if (VIR_REALLOC_N(cpus[node], nr_cpus_node[node]) < 0)
|
||||||
@ -328,7 +326,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
|
|||||||
if (nr_siblings) {
|
if (nr_siblings) {
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(siblings, nr_siblings) < 0)
|
siblings = g_new0(virCapsHostNUMACellSiblingInfo, nr_siblings);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (j = 0; j < nr_siblings; j++) {
|
for (j = 0; j < nr_siblings; j++) {
|
||||||
@ -590,8 +588,7 @@ libxlMakeDomainOSCaps(const char *machine,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
capsLoader->supported = VIR_TRISTATE_BOOL_YES;
|
capsLoader->supported = VIR_TRISTATE_BOOL_YES;
|
||||||
if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0)
|
capsLoader->values.values = g_new0(char *, nfirmwares);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nfirmwares; i++) {
|
for (i = 0; i < nfirmwares; i++) {
|
||||||
capsLoader->values.values[capsLoader->values.nvalues] = g_strdup(firmwares[i]->name);
|
capsLoader->values.values[capsLoader->values.nvalues] = g_strdup(firmwares[i]->name);
|
||||||
|
@ -613,9 +613,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
#ifdef LIBXL_HAVE_BUILDINFO_SERIAL_LIST
|
#ifdef LIBXL_HAVE_BUILDINFO_SERIAL_LIST
|
||||||
if (VIR_ALLOC_N(b_info->u.hvm.serial_list, def->nserials + 1) <
|
b_info->u.hvm.serial_list = *g_new0(libxl_string_list, def->nserials + 1);
|
||||||
0)
|
|
||||||
return -1;
|
|
||||||
for (i = 0; i < def->nserials; i++) {
|
for (i = 0; i < def->nserials; i++) {
|
||||||
if (libxlMakeChrdevStr(def->serials[i],
|
if (libxlMakeChrdevStr(def->serials[i],
|
||||||
&b_info->u.hvm.serial_list[i]) < 0)
|
&b_info->u.hvm.serial_list[i]) < 0)
|
||||||
@ -826,8 +824,7 @@ libxlMakeVnumaList(virDomainDefPtr def,
|
|||||||
/*
|
/*
|
||||||
* allocate the vnuma_nodes for assignment under b_info.
|
* allocate the vnuma_nodes for assignment under b_info.
|
||||||
*/
|
*/
|
||||||
if (VIR_ALLOC_N(vnuma_nodes, num_vnuma) < 0)
|
vnuma_nodes = g_new0(libxl_vnode_info, num_vnuma);
|
||||||
return -1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* parse the vnuma vnodes data.
|
* parse the vnuma vnodes data.
|
||||||
@ -870,8 +867,7 @@ libxlMakeVnumaList(virDomainDefPtr def,
|
|||||||
libxl_bitmap_dispose(&vcpu_bitmap);
|
libxl_bitmap_dispose(&vcpu_bitmap);
|
||||||
|
|
||||||
/* vdistances */
|
/* vdistances */
|
||||||
if (VIR_ALLOC_N(p->distances, num_vnuma) < 0)
|
p->distances = g_new0(uint32_t, num_vnuma);
|
||||||
goto cleanup;
|
|
||||||
p->num_distances = num_vnuma;
|
p->num_distances = num_vnuma;
|
||||||
|
|
||||||
for (j = 0; j < num_vnuma; j++)
|
for (j = 0; j < num_vnuma; j++)
|
||||||
@ -1193,8 +1189,7 @@ libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
|
|||||||
libxl_device_disk *x_disks;
|
libxl_device_disk *x_disks;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_disks, ndisks) < 0)
|
x_disks = g_new0(libxl_device_disk, ndisks);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < ndisks; i++) {
|
for (i = 0; i < ndisks; i++) {
|
||||||
if (libxlMakeDisk(l_disks[i], &x_disks[i]) < 0)
|
if (libxlMakeDisk(l_disks[i], &x_disks[i]) < 0)
|
||||||
@ -1464,8 +1459,7 @@ libxlMakeNicList(virDomainDefPtr def, libxl_domain_config *d_config)
|
|||||||
libxl_device_nic *x_nics;
|
libxl_device_nic *x_nics;
|
||||||
size_t i, nvnics = 0;
|
size_t i, nvnics = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_nics, nnics) < 0)
|
x_nics = g_new0(libxl_device_nic, nnics);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nnics; i++) {
|
for (i = 0; i < nnics; i++) {
|
||||||
if (virDomainNetGetActualType(l_nics[i]) == VIR_DOMAIN_NET_TYPE_HOSTDEV)
|
if (virDomainNetGetActualType(l_nics[i]) == VIR_DOMAIN_NET_TYPE_HOSTDEV)
|
||||||
@ -1567,12 +1561,8 @@ libxlMakeVfbList(virPortAllocatorRangePtr graphicsports,
|
|||||||
if (nvfbs == 0)
|
if (nvfbs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_vfbs, nvfbs) < 0)
|
x_vfbs = g_new0(libxl_device_vfb, nvfbs);
|
||||||
return -1;
|
x_vkbs = g_new0(libxl_device_vkb, nvfbs);
|
||||||
if (VIR_ALLOC_N(x_vkbs, nvfbs) < 0) {
|
|
||||||
VIR_FREE(x_vfbs);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nvfbs; i++) {
|
for (i = 0; i < nvfbs; i++) {
|
||||||
libxl_device_vkb_init(&x_vkbs[i]);
|
libxl_device_vkb_init(&x_vkbs[i]);
|
||||||
@ -1764,11 +1754,9 @@ libxlDriverConfigNew(void)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (VIR_ALLOC_N(cfg->firmwares, 1) < 0)
|
cfg->firmwares = g_new0(virFirmwarePtr, 1);
|
||||||
goto error;
|
|
||||||
cfg->nfirmwares = 1;
|
cfg->nfirmwares = 1;
|
||||||
if (VIR_ALLOC(cfg->firmwares[0]) < 0)
|
cfg->firmwares[0] = g_new0(virFirmware, 1);
|
||||||
goto error;
|
|
||||||
cfg->firmwares[0]->name = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
|
cfg->firmwares[0]->name = g_strdup(LIBXL_FIRMWARE_DIR "/ovmf.bin");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1776,8 +1764,7 @@ libxlDriverConfigNew(void)
|
|||||||
if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0)
|
if (VIR_REALLOC_N(cfg->firmwares, cfg->nfirmwares + 1) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
cfg->nfirmwares++;
|
cfg->nfirmwares++;
|
||||||
if (VIR_ALLOC(cfg->firmwares[cfg->nfirmwares - 1]) < 0)
|
cfg->firmwares[cfg->nfirmwares - 1] = g_new0(virFirmware, 1);
|
||||||
goto error;
|
|
||||||
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR "/hvmloader");
|
cfg->firmwares[cfg->nfirmwares - 1]->name = g_strdup(LIBXL_FIRMWARE_DIR "/hvmloader");
|
||||||
|
|
||||||
/* defaults for keepalive messages */
|
/* defaults for keepalive messages */
|
||||||
@ -2033,8 +2020,7 @@ libxlMakeChannelList(const char *channelDir,
|
|||||||
libxl_device_channel *x_channels;
|
libxl_device_channel *x_channels;
|
||||||
size_t i, nvchannels = 0;
|
size_t i, nvchannels = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_channels, nchannels) < 0)
|
x_channels = g_new0(libxl_device_channel, nchannels);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < nchannels; i++) {
|
for (i = 0; i < nchannels; i++) {
|
||||||
if (l_channels[i]->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL)
|
if (l_channels[i]->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL)
|
||||||
@ -2125,8 +2111,7 @@ libxlMakeDefaultUSBControllers(virDomainDefPtr def,
|
|||||||
|
|
||||||
/* Create USB controllers with 8 ports */
|
/* Create USB controllers with 8 ports */
|
||||||
ncontrollers = VIR_DIV_UP(nusbdevs, 8);
|
ncontrollers = VIR_DIV_UP(nusbdevs, 8);
|
||||||
if (VIR_ALLOC_N(x_controllers, ncontrollers) < 0)
|
x_controllers = g_new0(libxl_device_usbctrl, ncontrollers);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < ncontrollers; i++) {
|
for (i = 0; i < ncontrollers; i++) {
|
||||||
if (!(l_controller = virDomainControllerDefNew(VIR_DOMAIN_CONTROLLER_TYPE_USB)))
|
if (!(l_controller = virDomainControllerDefNew(VIR_DOMAIN_CONTROLLER_TYPE_USB)))
|
||||||
@ -2176,8 +2161,7 @@ libxlMakeUSBControllerList(virDomainDefPtr def, libxl_domain_config *d_config)
|
|||||||
if (nusbctrls == 0)
|
if (nusbctrls == 0)
|
||||||
return libxlMakeDefaultUSBControllers(def, d_config);
|
return libxlMakeDefaultUSBControllers(def, d_config);
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_usbctrls, nusbctrls) < 0)
|
x_usbctrls = g_new0(libxl_device_usbctrl, nusbctrls);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < ncontrollers && j < nusbctrls; i++) {
|
for (i = 0, j = 0; i < ncontrollers && j < nusbctrls; i++) {
|
||||||
if (l_controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
|
if (l_controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
|
||||||
@ -2253,8 +2237,7 @@ libxlMakeUSBList(virDomainDefPtr def, libxl_domain_config *d_config)
|
|||||||
if (nhostdevs == 0)
|
if (nhostdevs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_usbdevs, nhostdevs) < 0)
|
x_usbdevs = g_new0(libxl_device_usbdev, nhostdevs);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < nhostdevs; i++) {
|
for (i = 0, j = 0; i < nhostdevs; i++) {
|
||||||
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
@ -2316,8 +2299,7 @@ libxlMakePCIList(virDomainDefPtr def, libxl_domain_config *d_config)
|
|||||||
if (nhostdevs == 0)
|
if (nhostdevs == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(x_pcidevs, nhostdevs) < 0)
|
x_pcidevs = g_new0(libxl_device_pci, nhostdevs);
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < nhostdevs; i++) {
|
for (i = 0, j = 0; i < nhostdevs; i++) {
|
||||||
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
if (l_hostdevs[i]->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
|
||||||
|
@ -72,8 +72,7 @@ libxlDomainObjInitJob(libxlDomainObjPrivatePtr priv)
|
|||||||
if (virCondInit(&priv->job.cond) < 0)
|
if (virCondInit(&priv->job.cond) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_ALLOC(priv->job.current) < 0)
|
priv->job.current = g_new0(virDomainJobInfo, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -402,11 +401,7 @@ libxlDomainDefPostParse(virDomainDefPtr def,
|
|||||||
chrdef->target.port = 0;
|
chrdef->target.port = 0;
|
||||||
chrdef->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
chrdef->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->consoles, 1) < 0) {
|
def->consoles = g_new0(virDomainChrDefPtr, 1);
|
||||||
virDomainChrDefFree(chrdef);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
def->nconsoles = 1;
|
def->nconsoles = 1;
|
||||||
def->consoles[0] = chrdef;
|
def->consoles[0] = chrdef;
|
||||||
}
|
}
|
||||||
@ -429,8 +424,8 @@ libxlDomainDefPostParse(virDomainDefPtr def,
|
|||||||
/* add implicit balloon device */
|
/* add implicit balloon device */
|
||||||
if (def->memballoon == NULL) {
|
if (def->memballoon == NULL) {
|
||||||
virDomainMemballoonDefPtr memballoon;
|
virDomainMemballoonDefPtr memballoon;
|
||||||
if (VIR_ALLOC(memballoon) < 0)
|
memballoon = g_new0(virDomainMemballoonDef,
|
||||||
return -1;
|
1);
|
||||||
|
|
||||||
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_XEN;
|
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_XEN;
|
||||||
def->memballoon = memballoon;
|
def->memballoon = memballoon;
|
||||||
@ -695,8 +690,7 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
|
|||||||
* Start a thread to handle shutdown. We don't want to be tying up
|
* Start a thread to handle shutdown. We don't want to be tying up
|
||||||
* libxl's event machinery by doing a potentially lengthy shutdown.
|
* libxl's event machinery by doing a potentially lengthy shutdown.
|
||||||
*/
|
*/
|
||||||
if (VIR_ALLOC(shutdown_info) < 0)
|
shutdown_info = g_new0(struct libxlShutdownThreadInfo, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
shutdown_info->driver = driver;
|
shutdown_info->driver = driver;
|
||||||
shutdown_info->event = (libxl_event *)event;
|
shutdown_info->event = (libxl_event *)event;
|
||||||
@ -785,8 +779,7 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(xml, hdr.xmlLen) < 0)
|
xml = g_new0(char, hdr.xmlLen);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (saferead(fd, xml, hdr.xmlLen) != hdr.xmlLen) {
|
if (saferead(fd, xml, hdr.xmlLen) != hdr.xmlLen) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read XML"));
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read XML"));
|
||||||
|
@ -159,8 +159,7 @@ libxlFDRegisterEventHook(void *priv,
|
|||||||
int vir_events = VIR_EVENT_HANDLE_ERROR;
|
int vir_events = VIR_EVENT_HANDLE_ERROR;
|
||||||
libxlOSEventHookInfoPtr info;
|
libxlOSEventHookInfoPtr info;
|
||||||
|
|
||||||
if (VIR_ALLOC(info) < 0)
|
info = g_new0(libxlOSEventHookInfo, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
info->ctx = priv;
|
info->ctx = priv;
|
||||||
info->xl_priv = xl_priv;
|
info->xl_priv = xl_priv;
|
||||||
@ -239,8 +238,7 @@ libxlTimeoutRegisterEventHook(void *priv,
|
|||||||
gint64 res_ms;
|
gint64 res_ms;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
|
||||||
if (VIR_ALLOC(info) < 0)
|
info = g_new0(libxlOSEventHookInfo, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
info->ctx = priv;
|
info->ctx = priv;
|
||||||
info->xl_priv = xl_priv;
|
info->xl_priv = xl_priv;
|
||||||
@ -671,8 +669,7 @@ libxlStateInitialize(bool privileged,
|
|||||||
if (!libxlDriverShouldLoad(privileged))
|
if (!libxlDriverShouldLoad(privileged))
|
||||||
return VIR_DRV_STATE_INIT_SKIPPED;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
|
|
||||||
if (VIR_ALLOC(libxl_driver) < 0)
|
libxl_driver = g_new0(libxlDriverPrivate, 1);
|
||||||
return VIR_DRV_STATE_INIT_ERROR;
|
|
||||||
|
|
||||||
libxl_driver->lockFD = -1;
|
libxl_driver->lockFD = -1;
|
||||||
if (virMutexInit(&libxl_driver->lock) < 0) {
|
if (virMutexInit(&libxl_driver->lock) < 0) {
|
||||||
@ -2316,8 +2313,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
maplen = VIR_CPU_MAPLEN(nvcpus);
|
maplen = VIR_CPU_MAPLEN(nvcpus);
|
||||||
if (VIR_ALLOC_N(bitmask, maplen) < 0)
|
bitmask = g_new0(uint8_t, maplen);
|
||||||
goto endjob;
|
|
||||||
|
|
||||||
for (i = 0; i < nvcpus; ++i) {
|
for (i = 0; i < nvcpus; ++i) {
|
||||||
pos = i / 8;
|
pos = i / 8;
|
||||||
@ -2766,7 +2762,7 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(ret, len) < 0)
|
ret = g_new0(char, len);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virConfWriteMem(ret, &len, conf) < 0) {
|
if (virConfWriteMem(ret, &len, conf) < 0) {
|
||||||
@ -6373,15 +6369,15 @@ libxlGetDHCPInterfaces(virDomainObjPtr vm,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (n_leases) {
|
if (n_leases) {
|
||||||
ifaces_ret = g_renew(typeof(*ifaces_ret), ifaces_ret, ifaces_count + 1);
|
ifaces_ret = g_renew(virDomainInterfacePtr, ifaces_ret, ifaces_count + 1);
|
||||||
ifaces_ret[ifaces_count] = g_new0(typeof(**ifaces_ret), 1);
|
ifaces_ret[ifaces_count] = g_new0(virDomainInterface, 1);
|
||||||
iface = ifaces_ret[ifaces_count];
|
iface = ifaces_ret[ifaces_count];
|
||||||
ifaces_count++;
|
ifaces_count++;
|
||||||
|
|
||||||
/* Assuming each lease corresponds to a separate IP */
|
/* Assuming each lease corresponds to a separate IP */
|
||||||
iface->naddrs = n_leases;
|
iface->naddrs = n_leases;
|
||||||
|
|
||||||
iface->addrs = g_new0(typeof(*iface->addrs), iface->naddrs);
|
iface->addrs = g_new0(virDomainIPAddress, iface->naddrs);
|
||||||
iface->name = g_strdup(vm->def->nets[i]->ifname);
|
iface->name = g_strdup(vm->def->nets[i]->ifname);
|
||||||
iface->hwaddr = g_strdup(macaddr);
|
iface->hwaddr = g_strdup(macaddr);
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,7 @@ libxlMigrationCookieNew(virDomainObjPtr dom)
|
|||||||
{
|
{
|
||||||
libxlMigrationCookiePtr mig = NULL;
|
libxlMigrationCookiePtr mig = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(mig) < 0)
|
mig = g_new0(libxlMigrationCookie, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
mig->name = g_strdup(dom->def->name);
|
mig->name = g_strdup(dom->def->name);
|
||||||
|
|
||||||
@ -160,8 +159,7 @@ libxlMigrationEatCookie(const char *cookiein,
|
|||||||
* specify a stream version.
|
* specify a stream version.
|
||||||
*/
|
*/
|
||||||
if (!cookiein || !cookieinlen) {
|
if (!cookiein || !cookieinlen) {
|
||||||
if (VIR_ALLOC(mig) < 0)
|
mig = g_new0(libxlMigrationCookie, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
mig->xenMigStreamVer = 1;
|
mig->xenMigStreamVer = 1;
|
||||||
*migout = mig;
|
*migout = mig;
|
||||||
@ -176,8 +174,7 @@ libxlMigrationEatCookie(const char *cookiein,
|
|||||||
|
|
||||||
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
|
VIR_DEBUG("cookielen=%d cookie='%s'", cookieinlen, NULLSTR(cookiein));
|
||||||
|
|
||||||
if (VIR_ALLOC(mig) < 0)
|
mig = g_new0(libxlMigrationCookie, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!(doc = virXMLParseStringCtxt(cookiein,
|
if (!(doc = virXMLParseStringCtxt(cookiein,
|
||||||
_("(libxl_migration_cookie)"),
|
_("(libxl_migration_cookie)"),
|
||||||
@ -313,8 +310,7 @@ libxlMigrateDstReceive(virNetSocketPtr sock,
|
|||||||
*/
|
*/
|
||||||
args->recvfd = recvfd;
|
args->recvfd = recvfd;
|
||||||
VIR_FREE(priv->migrationDstReceiveThr);
|
VIR_FREE(priv->migrationDstReceiveThr);
|
||||||
if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
|
priv->migrationDstReceiveThr = g_new0(virThread, 1);
|
||||||
goto fail;
|
|
||||||
|
|
||||||
name = g_strdup_printf("mig-%s", args->vm->def->name);
|
name = g_strdup_printf("mig-%s", args->vm->def->name);
|
||||||
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
|
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
|
||||||
@ -614,8 +610,7 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn,
|
|||||||
mig = NULL;
|
mig = NULL;
|
||||||
|
|
||||||
VIR_FREE(priv->migrationDstReceiveThr);
|
VIR_FREE(priv->migrationDstReceiveThr);
|
||||||
if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0)
|
priv->migrationDstReceiveThr = g_new0(virThread, 1);
|
||||||
goto error;
|
|
||||||
name = g_strdup_printf("mig-%s", args->vm->def->name);
|
name = g_strdup_printf("mig-%s", args->vm->def->name);
|
||||||
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
|
if (virThreadCreateFull(priv->migrationDstReceiveThr, true,
|
||||||
libxlDoMigrateDstReceive,
|
libxlDoMigrateDstReceive,
|
||||||
@ -849,8 +844,7 @@ static void libxlTunnel3MigrationSrcFunc(void *arg)
|
|||||||
struct pollfd fds[1];
|
struct pollfd fds[1];
|
||||||
int timeout = -1;
|
int timeout = -1;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0)
|
buffer = g_new0(char, TUNNEL_SEND_BUF_SIZE);
|
||||||
return;
|
|
||||||
|
|
||||||
fds[0].fd = data->srcFD;
|
fds[0].fd = data->srcFD;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -920,8 +914,7 @@ libxlMigrationSrcStartTunnel(libxlDriverPrivatePtr driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autofree char *name = NULL;
|
g_autofree char *name = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(tc) < 0)
|
tc = g_new0(struct libxlTunnelControl, 1);
|
||||||
goto out;
|
|
||||||
*tnl = tc;
|
*tnl = tc;
|
||||||
|
|
||||||
tc->dataFD[0] = -1;
|
tc->dataFD[0] = -1;
|
||||||
|
@ -253,8 +253,7 @@ xenConfigSetInt(virConfPtr conf, const char *setting, long long l)
|
|||||||
l, setting);
|
l, setting);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (VIR_ALLOC(value) < 0)
|
value = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
value->type = VIR_CONF_LLONG;
|
value->type = VIR_CONF_LLONG;
|
||||||
value->next = NULL;
|
value->next = NULL;
|
||||||
@ -269,8 +268,7 @@ xenConfigSetString(virConfPtr conf, const char *setting, const char *str)
|
|||||||
{
|
{
|
||||||
virConfValuePtr value = NULL;
|
virConfValuePtr value = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(value) < 0)
|
value = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
value->type = VIR_CONF_STRING;
|
value->type = VIR_CONF_STRING;
|
||||||
value->next = NULL;
|
value->next = NULL;
|
||||||
@ -554,10 +552,10 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (strval) {
|
if (strval) {
|
||||||
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
|
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
|
||||||
VIR_ALLOC(timer) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
timer = g_new0(virDomainTimerDef, 1);
|
||||||
timer->name = VIR_DOMAIN_TIMER_NAME_TSC;
|
timer->name = VIR_DOMAIN_TIMER_NAME_TSC;
|
||||||
timer->present = 1;
|
timer->present = 1;
|
||||||
timer->tickpolicy = -1;
|
timer->tickpolicy = -1;
|
||||||
@ -627,10 +625,10 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (val != -1) {
|
if (val != -1) {
|
||||||
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
|
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0)
|
||||||
VIR_ALLOC(timer) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
timer = g_new0(virDomainTimerDef, 1);
|
||||||
timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
|
timer->name = VIR_DOMAIN_TIMER_NAME_HPET;
|
||||||
timer->present = val;
|
timer->present = val;
|
||||||
timer->tickpolicy = -1;
|
timer->tickpolicy = -1;
|
||||||
@ -666,8 +664,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
|
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (val) {
|
if (val) {
|
||||||
if (VIR_ALLOC(graphics) < 0)
|
graphics = g_new0(virDomainGraphicsDef, 1);
|
||||||
goto cleanup;
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
||||||
if (xenConfigGetBool(conf, "vncunused", &val, 1) < 0)
|
if (xenConfigGetBool(conf, "vncunused", &val, 1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -689,8 +686,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = graphics;
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
graphics = NULL;
|
||||||
@ -698,15 +694,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (xenConfigGetBool(conf, "sdl", &val, 0) < 0)
|
if (xenConfigGetBool(conf, "sdl", &val, 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (val) {
|
if (val) {
|
||||||
if (VIR_ALLOC(graphics) < 0)
|
graphics = g_new0(virDomainGraphicsDef, 1);
|
||||||
goto cleanup;
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
||||||
if (xenConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0)
|
if (xenConfigCopyStringOpt(conf, "display", &graphics->data.sdl.display) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0)
|
if (xenConfigCopyStringOpt(conf, "xauthority", &graphics->data.sdl.xauth) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = graphics;
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
graphics = NULL;
|
||||||
@ -729,8 +723,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(graphics) < 0)
|
graphics = g_new0(virDomainGraphicsDef, 1);
|
||||||
goto cleanup;
|
|
||||||
if (strstr(key, "type=sdl"))
|
if (strstr(key, "type=sdl"))
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
||||||
else
|
else
|
||||||
@ -785,8 +778,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
VIR_FREE(listenAddr);
|
VIR_FREE(listenAddr);
|
||||||
}
|
}
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = graphics;
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
graphics = NULL;
|
graphics = NULL;
|
||||||
@ -962,8 +954,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
|
|||||||
!(chr = xenParseSxprChar(parallel, NULL)))
|
!(chr = xenParseSxprChar(parallel, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (chr) {
|
if (chr) {
|
||||||
if (VIR_ALLOC_N(def->parallels, 1) < 0)
|
def->parallels = g_new0(virDomainChrDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
|
||||||
chr->target.port = 0;
|
chr->target.port = 0;
|
||||||
@ -1010,8 +1001,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
|
|||||||
!(chr = xenParseSxprChar(serial, NULL)))
|
!(chr = xenParseSxprChar(serial, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (chr) {
|
if (chr) {
|
||||||
if (VIR_ALLOC_N(def->serials, 1) < 0)
|
def->serials = g_new0(virDomainChrDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
|
||||||
chr->target.port = 0;
|
chr->target.port = 0;
|
||||||
def->serials[0] = chr;
|
def->serials[0] = chr;
|
||||||
@ -1019,8 +1009,7 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFormat)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (VIR_ALLOC_N(def->consoles, 1) < 0)
|
def->consoles = g_new0(virDomainChrDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
def->nconsoles = 1;
|
def->nconsoles = 1;
|
||||||
if (!(def->consoles[0] = xenParseSxprChar("pty", NULL)))
|
if (!(def->consoles[0] = xenParseSxprChar("pty", NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1051,15 +1040,11 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge)
|
|||||||
if (virStrToLong_ui(vlanstr, NULL, 10, &tag) < 0)
|
if (virStrToLong_ui(vlanstr, NULL, 10, &tag) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(net->vlan.tag, 1) < 0)
|
net->vlan.tag = g_new0(unsigned int, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
net->vlan.tag[0] = tag;
|
net->vlan.tag[0] = tag;
|
||||||
net->vlan.nTags = 1;
|
net->vlan.nTags = 1;
|
||||||
|
|
||||||
if (VIR_ALLOC(net->virtPortProfile) < 0)
|
net->virtPortProfile = g_new0(virNetDevVPortProfile, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
|
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
|
||||||
return 0;
|
return 0;
|
||||||
} else if ((vlanstr = strchr(bridge, ':'))) {
|
} else if ((vlanstr = strchr(bridge, ':'))) {
|
||||||
@ -1076,10 +1061,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge)
|
|||||||
for (i = 1; vlanstr_list[i]; i++)
|
for (i = 1; vlanstr_list[i]; i++)
|
||||||
nvlans++;
|
nvlans++;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(net->vlan.tag, nvlans) < 0) {
|
net->vlan.tag = g_new0(unsigned int, nvlans);
|
||||||
g_strfreev(vlanstr_list);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 1; i <= nvlans; i++) {
|
for (i = 1; i <= nvlans; i++) {
|
||||||
if (virStrToLong_ui(vlanstr_list[i], NULL, 10, &tag) < 0) {
|
if (virStrToLong_ui(vlanstr_list[i], NULL, 10, &tag) < 0) {
|
||||||
@ -1092,9 +1074,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge)
|
|||||||
net->vlan.trunk = true;
|
net->vlan.trunk = true;
|
||||||
g_strfreev(vlanstr_list);
|
g_strfreev(vlanstr_list);
|
||||||
|
|
||||||
if (VIR_ALLOC(net->virtPortProfile) < 0)
|
net->virtPortProfile = g_new0(virNetDevVPortProfile, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
|
net->virtPortProfile->virtPortType = VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -1314,14 +1294,8 @@ xenParseVif(char *entry, const char *vif_typename)
|
|||||||
if (xenParseSxprVifRate(rate, &kbytes_per_sec) < 0)
|
if (xenParseSxprVifRate(rate, &kbytes_per_sec) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_ALLOC(bandwidth) < 0)
|
bandwidth = g_new0(virNetDevBandwidth, 1);
|
||||||
goto cleanup;
|
bandwidth->out = g_new0(virNetDevBandwidthRate, 1);
|
||||||
|
|
||||||
if (VIR_ALLOC(bandwidth->out) < 0) {
|
|
||||||
VIR_FREE(bandwidth);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
bandwidth->out->average = kbytes_per_sec;
|
bandwidth->out->average = kbytes_per_sec;
|
||||||
net->bandwidth = bandwidth;
|
net->bandwidth = bandwidth;
|
||||||
}
|
}
|
||||||
@ -1393,15 +1367,11 @@ xenParseSxprSound(virDomainDefPtr def,
|
|||||||
* Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
|
* Hence use of MODEL_ES1370 + 1, instead of MODEL_LAST
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->sounds,
|
def->sounds = g_new0(virDomainSoundDefPtr,
|
||||||
VIR_DOMAIN_SOUND_MODEL_ES1370 + 1) < 0)
|
VIR_DOMAIN_SOUND_MODEL_ES1370 + 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
|
for (i = 0; i < (VIR_DOMAIN_SOUND_MODEL_ES1370 + 1); i++) {
|
||||||
virDomainSoundDefPtr sound;
|
virDomainSoundDefPtr sound = g_new0(virDomainSoundDef, 1);
|
||||||
if (VIR_ALLOC(sound) < 0)
|
|
||||||
return -1;
|
|
||||||
sound->model = i;
|
sound->model = i;
|
||||||
def->sounds[def->nsounds++] = sound;
|
def->sounds[def->nsounds++] = sound;
|
||||||
}
|
}
|
||||||
@ -1424,8 +1394,7 @@ xenParseSxprSound(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(sound) < 0)
|
sound = g_new0(virDomainSoundDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
|
if ((sound->model = virDomainSoundModelTypeFromString(model)) < 0) {
|
||||||
VIR_FREE(sound);
|
VIR_FREE(sound);
|
||||||
@ -1661,8 +1630,7 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial)
|
|||||||
virBufferAddLit(&buf, "none");
|
virBufferAddLit(&buf, "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = virBufferContentAndReset(&buf);
|
val->str = virBufferContentAndReset(&buf);
|
||||||
@ -1684,8 +1652,7 @@ xenMakeIPList(virNetDevIPInfoPtr guestIP)
|
|||||||
char **address_array;
|
char **address_array;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(address_array, guestIP->nips + 1) < 0)
|
address_array = g_new0(char *, guestIP->nips + 1);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < guestIP->nips; i++) {
|
for (i = 0; i < guestIP->nips; i++) {
|
||||||
address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address);
|
address_array[i] = virSocketAddrFormat(&guestIP->ips[i]->address);
|
||||||
@ -1822,9 +1789,7 @@ xenFormatNet(virConnectPtr conn,
|
|||||||
if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
|
if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
|
||||||
virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
|
virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = virBufferContentAndReset(&buf);
|
val->str = virBufferContentAndReset(&buf);
|
||||||
tmp = list->list;
|
tmp = list->list;
|
||||||
@ -1854,8 +1819,7 @@ xenFormatPCI(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (!hasPCI)
|
if (!hasPCI)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(pciVal) < 0)
|
pciVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
pciVal->type = VIR_CONF_LIST;
|
pciVal->type = VIR_CONF_LIST;
|
||||||
pciVal->list = NULL;
|
pciVal->list = NULL;
|
||||||
@ -1888,10 +1852,7 @@ xenFormatPCI(virConfPtr conf, virDomainDefPtr def)
|
|||||||
permissive_str);
|
permissive_str);
|
||||||
|
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0) {
|
val = g_new0(virConfValue, 1);
|
||||||
VIR_FREE(buf);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = buf;
|
val->str = buf;
|
||||||
tmp = pciVal->list;
|
tmp = pciVal->list;
|
||||||
@ -1913,10 +1874,6 @@ xenFormatPCI(virConfPtr conf, virDomainDefPtr def)
|
|||||||
VIR_FREE(pciVal);
|
VIR_FREE(pciVal);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
virConfFreeValue(pciVal);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2098,9 +2055,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(serialVal) < 0)
|
serialVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
serialVal->type = VIR_CONF_LIST;
|
serialVal->type = VIR_CONF_LIST;
|
||||||
serialVal->list = NULL;
|
serialVal->list = NULL;
|
||||||
|
|
||||||
@ -2385,16 +2340,8 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
|
|
||||||
vfbstr = virBufferContentAndReset(&buf);
|
vfbstr = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
if (VIR_ALLOC(vfb) < 0) {
|
vfb = g_new0(virConfValue, 1);
|
||||||
VIR_FREE(vfbstr);
|
disp = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_ALLOC(disp) < 0) {
|
|
||||||
VIR_FREE(vfb);
|
|
||||||
VIR_FREE(vfbstr);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
vfb->type = VIR_CONF_LIST;
|
vfb->type = VIR_CONF_LIST;
|
||||||
vfb->list = disp;
|
vfb->list = disp;
|
||||||
@ -2450,8 +2397,7 @@ xenFormatVif(virConfPtr conf,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
|
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
|
||||||
|
|
||||||
if (VIR_ALLOC(netVal) < 0)
|
netVal = g_new0(virConfValue, 1);
|
||||||
goto cleanup;
|
|
||||||
netVal->type = VIR_CONF_LIST;
|
netVal->type = VIR_CONF_LIST;
|
||||||
netVal->list = NULL;
|
netVal->list = NULL;
|
||||||
|
|
||||||
|
@ -110,9 +110,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (bios && STREQ(bios, "ovmf")) {
|
if (bios && STREQ(bios, "ovmf")) {
|
||||||
if (VIR_ALLOC(def->os.loader) < 0)
|
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
def->os.loader->type = VIR_DOMAIN_LOADER_TYPE_PFLASH;
|
||||||
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
def->os.loader->readonly = VIR_TRISTATE_BOOL_YES;
|
||||||
|
|
||||||
@ -121,8 +119,7 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
|
|||||||
for (i = 0; i < caps->nguests; i++) {
|
for (i = 0; i < caps->nguests; i++) {
|
||||||
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
|
if (caps->guests[i]->ostype == VIR_DOMAIN_OSTYPE_HVM &&
|
||||||
caps->guests[i]->arch.id == def->os.arch) {
|
caps->guests[i]->arch.id == def->os.arch) {
|
||||||
if (VIR_ALLOC(def->os.loader) < 0)
|
def->os.loader = g_new0(virDomainLoaderDef, 1);
|
||||||
return -1;
|
|
||||||
def->os.loader->path = g_strdup(caps->guests[i]->arch.defaultInfo.loader);
|
def->os.loader->path = g_strdup(caps->guests[i]->arch.defaultInfo.loader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,9 +342,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (val) {
|
if (val) {
|
||||||
if (VIR_ALLOC(graphics) < 0)
|
graphics = g_new0(virDomainGraphicsDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
||||||
if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
|
if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -394,8 +389,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
|
|||||||
else
|
else
|
||||||
graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_NO;
|
graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_NO;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
def->graphics = g_new0(virDomainGraphicsDefPtr, 1);
|
||||||
goto cleanup;
|
|
||||||
def->graphics[0] = graphics;
|
def->graphics[0] = graphics;
|
||||||
def->ngraphics = 1;
|
def->ngraphics = 1;
|
||||||
}
|
}
|
||||||
@ -702,8 +696,7 @@ xenParseXLDisk(virConfPtr conf, virDomainDefPtr def)
|
|||||||
libxl_device_disk *libxldisk;
|
libxl_device_disk *libxldisk;
|
||||||
virDomainDiskDefPtr disk = NULL;
|
virDomainDiskDefPtr disk = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(libxldisk) < 0)
|
libxldisk = g_new0(libxl_device_disk, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!(xluconf = xlu_cfg_init(stderr, "command line")))
|
if (!(xluconf = xlu_cfg_init(stderr, "command line")))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -868,8 +861,8 @@ xenParseXLInputDevs(virConfPtr conf, virDomainDefPtr def)
|
|||||||
STREQ(str, "mouse") ||
|
STREQ(str, "mouse") ||
|
||||||
STREQ(str, "keyboard"))) {
|
STREQ(str, "keyboard"))) {
|
||||||
virDomainInputDefPtr input;
|
virDomainInputDefPtr input;
|
||||||
if (VIR_ALLOC(input) < 0)
|
input = g_new0(virDomainInputDef,
|
||||||
return -1;
|
1);
|
||||||
|
|
||||||
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||||
if (STREQ(str, "mouse"))
|
if (STREQ(str, "mouse"))
|
||||||
@ -1397,8 +1390,7 @@ xenFormatXLCPUID(virConfPtr conf, virDomainDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* "host" + all features + NULL */
|
/* "host" + all features + NULL */
|
||||||
if (VIR_ALLOC_N(cpuid_pairs, def->cpu->nfeatures + 2) < 0)
|
cpuid_pairs = g_new0(char *, def->cpu->nfeatures + 2);
|
||||||
return -1;
|
|
||||||
|
|
||||||
cpuid_pairs[0] = g_strdup("host");
|
cpuid_pairs[0] = g_strdup("host");
|
||||||
|
|
||||||
@ -1455,8 +1447,7 @@ xenFormatXLVnode(virConfValuePtr list,
|
|||||||
{
|
{
|
||||||
virConfValuePtr numaPnode, tmp;
|
virConfValuePtr numaPnode, tmp;
|
||||||
|
|
||||||
if (VIR_ALLOC(numaPnode) < 0)
|
numaPnode = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Place VNODE directive */
|
/* Place VNODE directive */
|
||||||
numaPnode->type = VIR_CONF_STRING;
|
numaPnode->type = VIR_CONF_STRING;
|
||||||
@ -1487,10 +1478,10 @@ xenFormatXLVnuma(virConfValuePtr list,
|
|||||||
size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
|
size_t nodeSize = virDomainNumaGetNodeMemorySize(numa, node) / 1024;
|
||||||
g_autofree char *nodeVcpus = NULL;
|
g_autofree char *nodeVcpus = NULL;
|
||||||
|
|
||||||
if (!cpumask ||
|
if (!cpumask)
|
||||||
VIR_ALLOC(numaVnode) < 0)
|
return -1;
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
|
numaVnode = g_new0(virConfValue, 1);
|
||||||
numaVnode->type = VIR_CONF_LIST;
|
numaVnode->type = VIR_CONF_LIST;
|
||||||
numaVnode->list = NULL;
|
numaVnode->list = NULL;
|
||||||
|
|
||||||
@ -1527,7 +1518,6 @@ xenFormatXLVnuma(virConfValuePtr list,
|
|||||||
list->list = numaVnode;
|
list->list = numaVnode;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(nodeVcpus);
|
VIR_FREE(nodeVcpus);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1544,8 +1534,7 @@ xenFormatXLDomainVnuma(virConfPtr conf,
|
|||||||
if (numa == NULL)
|
if (numa == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_ALLOC(vnumaVal) < 0)
|
vnumaVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
vnumaVal->type = VIR_CONF_LIST;
|
vnumaVal->type = VIR_CONF_LIST;
|
||||||
vnumaVal->list = NULL;
|
vnumaVal->list = NULL;
|
||||||
@ -1772,8 +1761,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
|
|||||||
if (target)
|
if (target)
|
||||||
virBufferAsprintf(&buf, ",target=%s", target);
|
virBufferAsprintf(&buf, ",target=%s", target);
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = virBufferContentAndReset(&buf);
|
val->str = virBufferContentAndReset(&buf);
|
||||||
@ -1798,8 +1786,7 @@ xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def)
|
|||||||
virConfValuePtr diskVal;
|
virConfValuePtr diskVal;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC(diskVal) < 0)
|
diskVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
diskVal->type = VIR_CONF_LIST;
|
diskVal->type = VIR_CONF_LIST;
|
||||||
diskVal->list = NULL;
|
diskVal->list = NULL;
|
||||||
@ -1923,9 +1910,7 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr def)
|
|||||||
virConfValuePtr usbdevices = NULL, lastdev;
|
virConfValuePtr usbdevices = NULL, lastdev;
|
||||||
|
|
||||||
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||||
if (VIR_ALLOC(usbdevices) < 0)
|
usbdevices = g_new0(virConfValue, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
usbdevices->type = VIR_CONF_LIST;
|
usbdevices->type = VIR_CONF_LIST;
|
||||||
usbdevices->list = NULL;
|
usbdevices->list = NULL;
|
||||||
lastdev = NULL;
|
lastdev = NULL;
|
||||||
@ -1949,12 +1934,10 @@ xenFormatXLInputDevs(virConfPtr conf, virDomainDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastdev == NULL) {
|
if (lastdev == NULL) {
|
||||||
if (VIR_ALLOC(lastdev) < 0)
|
lastdev = g_new0(virConfValue, 1);
|
||||||
goto error;
|
|
||||||
usbdevices->list = lastdev;
|
usbdevices->list = lastdev;
|
||||||
} else {
|
} else {
|
||||||
if (VIR_ALLOC(lastdev->next) < 0)
|
lastdev->next = g_new0(virConfValue, 1);
|
||||||
goto error;
|
|
||||||
lastdev = lastdev->next;
|
lastdev = lastdev->next;
|
||||||
}
|
}
|
||||||
lastdev->type = VIR_CONF_STRING;
|
lastdev->type = VIR_CONF_STRING;
|
||||||
@ -2000,8 +1983,7 @@ xenFormatXLUSBController(virConfPtr conf,
|
|||||||
if (!hasUSBCtrl)
|
if (!hasUSBCtrl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(usbctrlVal) < 0)
|
usbctrlVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
usbctrlVal->type = VIR_CONF_LIST;
|
usbctrlVal->type = VIR_CONF_LIST;
|
||||||
usbctrlVal->list = NULL;
|
usbctrlVal->list = NULL;
|
||||||
@ -2030,9 +2012,7 @@ xenFormatXLUSBController(virConfPtr conf,
|
|||||||
virBufferAsprintf(&buf, "ports=%x",
|
virBufferAsprintf(&buf, "ports=%x",
|
||||||
def->controllers[i]->opts.usbopts.ports);
|
def->controllers[i]->opts.usbopts.ports);
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = virBufferContentAndReset(&buf);
|
val->str = virBufferContentAndReset(&buf);
|
||||||
tmp = usbctrlVal->list;
|
tmp = usbctrlVal->list;
|
||||||
@ -2080,8 +2060,7 @@ xenFormatXLUSB(virConfPtr conf,
|
|||||||
if (!hasUSB)
|
if (!hasUSB)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(usbVal) < 0)
|
usbVal = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
usbVal->type = VIR_CONF_LIST;
|
usbVal->type = VIR_CONF_LIST;
|
||||||
usbVal->list = NULL;
|
usbVal->list = NULL;
|
||||||
@ -2096,10 +2075,7 @@ xenFormatXLUSB(virConfPtr conf,
|
|||||||
def->hostdevs[i]->source.subsys.u.usb.bus,
|
def->hostdevs[i]->source.subsys.u.usb.bus,
|
||||||
def->hostdevs[i]->source.subsys.u.usb.device);
|
def->hostdevs[i]->source.subsys.u.usb.device);
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0) {
|
val = g_new0(virConfValue, 1);
|
||||||
VIR_FREE(buf);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = buf;
|
val->str = buf;
|
||||||
tmp = usbVal->list;
|
tmp = usbVal->list;
|
||||||
@ -2121,10 +2097,6 @@ xenFormatXLUSB(virConfPtr conf,
|
|||||||
VIR_FREE(usbVal);
|
VIR_FREE(usbVal);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
virConfFreeValue(usbVal);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -2154,9 +2126,7 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel)
|
|||||||
/* name */
|
/* name */
|
||||||
virBufferAsprintf(&buf, "name=%s", channel->target.name);
|
virBufferAsprintf(&buf, "name=%s", channel->target.name);
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = virBufferContentAndReset(&buf);
|
val->str = virBufferContentAndReset(&buf);
|
||||||
tmp = list->list;
|
tmp = list->list;
|
||||||
@ -2175,8 +2145,7 @@ xenFormatXLDomainChannels(virConfPtr conf, virDomainDefPtr def)
|
|||||||
virConfValuePtr channelVal = NULL;
|
virConfValuePtr channelVal = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC(channelVal) < 0)
|
channelVal = g_new0(virConfValue, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
channelVal->type = VIR_CONF_LIST;
|
channelVal->type = VIR_CONF_LIST;
|
||||||
channelVal->list = NULL;
|
channelVal->list = NULL;
|
||||||
@ -2219,8 +2188,7 @@ xenFormatXLDomainNamespaceData(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (nsdata->num_args == 0)
|
if (nsdata->num_args == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(args) < 0)
|
args = g_new0(virConfValue, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
args->type = VIR_CONF_LIST;
|
args->type = VIR_CONF_LIST;
|
||||||
args->list = NULL;
|
args->list = NULL;
|
||||||
@ -2228,8 +2196,7 @@ xenFormatXLDomainNamespaceData(virConfPtr conf, virDomainDefPtr def)
|
|||||||
for (i = 0; i < nsdata->num_args; i++) {
|
for (i = 0; i < nsdata->num_args; i++) {
|
||||||
virConfValuePtr val, tmp;
|
virConfValuePtr val, tmp;
|
||||||
|
|
||||||
if (VIR_ALLOC(val) < 0)
|
val = g_new0(virConfValue, 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
val->type = VIR_CONF_STRING;
|
val->type = VIR_CONF_STRING;
|
||||||
val->str = g_strdup(nsdata->args[i]);
|
val->str = g_strdup(nsdata->args[i]);
|
||||||
|
@ -148,8 +148,7 @@ xenParseXMDisk(char *entry, int hvm)
|
|||||||
if (!(offset = strchr(head, ',')))
|
if (!(offset = strchr(head, ',')))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(disk->dst, (offset - head) + 1) < 0)
|
disk->dst = g_new0(char, (offset - head) + 1);
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (virStrncpy(disk->dst, head, offset - head,
|
if (virStrncpy(disk->dst, head, offset - head,
|
||||||
(offset - head) + 1) < 0) {
|
(offset - head) + 1) < 0) {
|
||||||
@ -368,8 +367,7 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def)
|
|||||||
virConfValuePtr diskVal = NULL;
|
virConfValuePtr diskVal = NULL;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
if (VIR_ALLOC(diskVal) < 0)
|
diskVal = g_new0(virConfValue, 1);
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
diskVal->type = VIR_CONF_LIST;
|
diskVal->type = VIR_CONF_LIST;
|
||||||
diskVal->list = NULL;
|
diskVal->list = NULL;
|
||||||
@ -411,8 +409,7 @@ xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def)
|
|||||||
STREQ(str, "mouse") ||
|
STREQ(str, "mouse") ||
|
||||||
STREQ(str, "keyboard"))) {
|
STREQ(str, "keyboard"))) {
|
||||||
virDomainInputDefPtr input;
|
virDomainInputDefPtr input;
|
||||||
if (VIR_ALLOC(input) < 0)
|
input = g_new0(virDomainInputDef, 1);
|
||||||
return -1;
|
|
||||||
|
|
||||||
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||||
if (STREQ(str, "mouse"))
|
if (STREQ(str, "mouse"))
|
||||||
|
Loading…
Reference in New Issue
Block a user