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