if (!def)
return;
- for (i = 0; i < nvcpupin; i++) {
+ for (i = 0; i < nvcpupin; i++)
virDomainVcpuPinDefFree(def[i]);
- }
VIR_FREE(def);
}
void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info)
{
VIR_FREE(info->alias);
- if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB)
VIR_FREE(info->addr.usb.port);
- }
memset(&info->addr, 0, sizeof(info->addr));
info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
VIR_FREE(info->romfile);
def->info.addr.drive.unit = idx % 15;
/* Skip the SCSI controller at unit 7 */
- if (def->info.addr.drive.unit >= 7) {
+ if (def->info.addr.drive.unit >= 7)
++def->info.addr.drive.unit;
- }
} else {
/* For a narrow SCSI bus we define the default mapping to be
* 7 units per bus, 1 bus per controller, many controllers */
error:
ctxt->node = saved_node;
- for (; i > 0; i--) {
+ for (; i > 0; i--)
virSecurityLabelDefFree(def->seclabels[i - 1]);
- }
VIR_FREE(def->seclabels);
def->nseclabels = 0;
VIR_FREE(list);
return 0;
error:
- for (i = 0; i < nseclabels; i++) {
+ for (i = 0; i < nseclabels; i++)
virSecurityDeviceLabelDefFree(seclabels[i]);
- }
VIR_FREE(seclabels);
VIR_FREE(list);
return -1;
goto error;
}
} else {
- if (def->bus == VIR_DOMAIN_DISK_BUS_USB) {
+ if (def->bus == VIR_DOMAIN_DISK_BUS_USB)
def->removable = VIR_TRISTATE_SWITCH_ABSENT;
- }
}
if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
if (cur->type == XML_ELEMENT_NODE) {
if (xmlStrEqual(cur->name, BAD_CAST "target")) {
seenTarget = true;
- if (virDomainChrDefParseTargetXML(def, cur) < 0) {
+ if (virDomainChrDefParseTargetXML(def, cur) < 0)
goto error;
- }
}
}
cur = cur->next;
if (virDomainGraphicsListenGetType(def, i)
== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
found = virDomainGraphicsListenGetAddress(def, i);
- if (STREQ_NULLABLE(found, listenAddr)) {
+ if (STREQ_NULLABLE(found, listenAddr))
matched = true;
- }
break;
}
}
def->data.rdp.port = 0;
if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) {
- if (STREQ(replaceUser, "yes")) {
+ if (STREQ(replaceUser, "yes"))
def->data.rdp.replaceUser = true;
- }
VIR_FREE(replaceUser);
}
if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) {
- if (STREQ(multiUser, "yes")) {
+ if (STREQ(multiUser, "yes"))
def->data.rdp.multiUser = true;
- }
VIR_FREE(multiUser);
}
if (remaining < 0)
goto error;
- if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
+ if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC)
def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR;
- }
if (virDomainDeviceInfoParseXML(node, bootHash, &def->info,
flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0)
goto error;
ctxt->node = node;
- if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->usbdevs, n) < 0)
goto error;
}
/* analysis of the boot devices */
- if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0)
goto cleanup;
- }
if (n > 0 && deviceBoot) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
def->os.init = virXPathString("string(./os/init[1])", ctxt);
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
- if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
goto error;
- }
if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
goto error;
VIR_FREE(nodes);
/* analysis of the filesystems */
- if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->fss, n) < 0)
goto error;
for (i = 0; i < n; i++) {
VIR_FREE(nodes);
/* analysis of the network devices */
- if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->nets, n) < 0)
goto error;
for (i = 0; i < n; i++) {
/* analysis of the smartcard devices */
- if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->smartcards, n) < 0)
goto error;
/* analysis of the character devices */
- if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->parallels, n) < 0)
goto error;
}
VIR_FREE(nodes);
- if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->channels, n) < 0)
goto error;
/* analysis of the input devices */
- if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->inputs, n) < 0)
goto error;
VIR_FREE(nodes);
/* analysis of the graphics devices */
- if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->graphics, n) < 0)
goto error;
for (i = 0; i < n; i++) {
}
/* analysis of the sound devices */
- if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->sounds, n) < 0)
goto error;
for (i = 0; i < n; i++) {
VIR_FREE(nodes);
/* analysis of the video devices */
- if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->videos, n) < 0)
goto error;
for (i = 0; i < n; i++) {
}
/* analysis of the host devices */
- if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0)
goto error;
for (i = 0; i < n; i++) {
/* analysis of the watchdog devices */
def->watchdog = NULL;
- if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0)
goto error;
- }
if (n > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only a single watchdog device is supported"));
/* analysis of the memballoon devices */
def->memballoon = NULL;
- if ((n = virXPathNodeSet("./devices/memballoon", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/memballoon", ctxt, &nodes)) < 0)
goto error;
- }
if (n > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only a single memory balloon device is supported"));
}
VIR_FREE(nodes);
- if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0)
goto error;
- }
if (n > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
}
/* analysis of the hub devices */
- if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->hubs, n) < 0)
goto error;
for (i = 0; i < n; i++) {
VIR_FREE(nodes);
/* analysis of the redirected devices */
- if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->redirdevs, n) < 0)
goto error;
for (i = 0; i < n; i++) {
VIR_FREE(nodes);
/* analysis of the redirection filter rules */
- if ((n = virXPathNodeSet("./devices/redirfilter", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/redirfilter", ctxt, &nodes)) < 0)
goto error;
- }
if (n > 1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only one set of redirection filter rule is supported"));
/* analysis of the panic devices */
def->panic = NULL;
- if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0)
goto error;
- }
if (n > 1) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("only a single panic device is supported"));
}
/* analysis of the shmem devices */
- if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0)
goto error;
- }
if (n && VIR_ALLOC_N(def->shmems, n) < 0)
goto error;
}
obj->pid = (pid_t)val;
- if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0) {
+ if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0)
goto error;
- }
for (i = 0; i < n; i++) {
char *str = virXMLPropString(nodes[i], "flag");
if (str) {
int
virDomainEmulatorPinDel(virDomainDefPtr def)
{
- if (!def->cputune.emulatorpin) {
+ if (!def->cputune.emulatorpin)
return 0;
- }
virDomainVcpuPinDefFree(def->cputune.emulatorpin);
def->cputune.emulatorpin = NULL;
"<controller type='%s' index='%u'",
type, def->idx);
- if (model) {
+ if (model)
virBufferEscapeString(buf, " model='%s'", model);
- }
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
}
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: {
- if (def->target.name) {
+ if (def->target.name)
virBufferEscapeString(buf, " name='%s'", def->target.name);
- }
break;
}
}
if (def->name == VIR_DOMAIN_TIMER_NAME_TSC) {
- if (def->frequency > 0) {
+ if (def->frequency > 0)
virBufferAsprintf(buf, " frequency='%lu'", def->frequency);
- }
if (def->mode != -1) {
const char *mode
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferAddLit(buf, "<catchup");
- if (def->catchup.threshold > 0) {
+ if (def->catchup.threshold > 0)
virBufferAsprintf(buf, " threshold='%lu'", def->catchup.threshold);
- }
- if (def->catchup.slew > 0) {
+ if (def->catchup.slew > 0)
virBufferAsprintf(buf, " slew='%lu'", def->catchup.slew);
- }
- if (def->catchup.limit > 0) {
+ if (def->catchup.limit > 0)
virBufferAsprintf(buf, " limit='%lu'", def->catchup.limit);
- }
virBufferAddLit(buf, "/>\n");
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</timer>\n");
return iface->data.bridge.brname;
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
iface->data.network.actual &&
- iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE)
return iface->data.network.actual->data.bridge.brname;
- }
return NULL;
}
return iface->data.direct.linkdev;
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
iface->data.network.actual &&
- iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT)
return iface->data.network.actual->data.direct.linkdev;
- }
return NULL;
}
return iface->data.direct.mode;
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
iface->data.network.actual &&
- iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT)
return iface->data.network.actual->data.direct.mode;
- }
return 0;
}
return &iface->data.hostdev.def;
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
iface->data.network.actual &&
- iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+ iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
return &iface->data.network.actual->data.hostdev.def;
- }
return NULL;
}
* its bandwidth rather than the NetDef's bandwidth.
*/
if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK &&
- iface->data.network.actual) {
+ iface->data.network.actual)
return iface->data.network.actual->bandwidth;
- }
return iface->bandwidth;
}
{
size_t i;
- for (i = 0; i < def->npfs && def->pfs; i++) {
+ for (i = 0; i < def->npfs && def->pfs; i++)
virNetworkForwardPfDefClear(&def->pfs[i]);
- }
VIR_FREE(def->pfs);
- for (i = 0; i < def->nifs && def->ifs; i++) {
+ for (i = 0; i < def->nifs && def->ifs; i++)
virNetworkForwardIfDefClear(&def->ifs[i]);
- }
VIR_FREE(def->ifs);
def->nifs = def->npfs = 0;
}
virNetworkForwardDefClear(&def->forward);
- for (i = 0; i < def->nips && def->ips; i++) {
+ for (i = 0; i < def->nips && def->ips; i++)
virNetworkIpDefClear(&def->ips[i]);
- }
VIR_FREE(def->ips);
- for (i = 0; i < def->nroutes && def->routes; i++) {
+ for (i = 0; i < def->nroutes && def->routes; i++)
virNetworkRouteDefClear(&def->routes[i]);
- }
VIR_FREE(def->routes);
- for (i = 0; i < def->nPortGroups && def->portGroups; i++) {
+ for (i = 0; i < def->nPortGroups && def->portGroups; i++)
virPortGroupDefClear(&def->portGroups[i]);
- }
VIR_FREE(def->portGroups);
virNetworkDNSDefClear(&def->dns);
if (!def->ips || n >= def->nips)
return NULL;
- if (family == AF_UNSPEC) {
+ if (family == AF_UNSPEC)
return &def->ips[n];
- }
/* find the nth ip of type "family" */
for (i = 0; i < def->nips; i++) {
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
virNetworkIpDefClear(def);
- }
VIR_FREE(address);
VIR_FREE(netmask);
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
virNetworkRouteDefClear(def);
- }
VIR_FREE(address);
VIR_FREE(netmask);
VIR_FREE(gateway);
result = 0;
cleanup:
- if (result < 0) {
+ if (result < 0)
virPortGroupDefClear(def);
- }
VIR_FREE(isDefault);
VIR_FREE(trustGuestRxFilters);
virBufferAddLit(buf, "<ip");
- if (def->family) {
+ if (def->family)
virBufferAsprintf(buf, " family='%s'", def->family);
- }
if (VIR_SOCKET_ADDR_VALID(&def->address)) {
char *addr = virSocketAddrFormat(&def->address);
if (!addr)
virBufferAsprintf(buf, " netmask='%s'", addr);
VIR_FREE(addr);
}
- if (def->prefix > 0) {
+ if (def->prefix > 0)
virBufferAsprintf(buf, " prefix='%u'", def->prefix);
- }
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
virBufferAddLit(buf, "<route");
- if (def->family) {
+ if (def->family)
virBufferAsprintf(buf, " family='%s'", def->family);
- }
if (VIR_SOCKET_ADDR_VALID(&def->address)) {
char *addr = virSocketAddrFormat(&def->address);
virBufferAsprintf(buf, " netmask='%s'", addr);
VIR_FREE(addr);
}
- if (def->has_prefix) {
+ if (def->has_prefix)
virBufferAsprintf(buf, " prefix='%u'", def->prefix);
- }
if (VIR_SOCKET_ADDR_VALID(&def->gateway)) {
char *addr = virSocketAddrFormat(&def->gateway);
if (!addr)
virBufferAsprintf(buf, " gateway='%s'", addr);
VIR_FREE(addr);
}
- if (def->has_metric && def->metric > 0) {
+ if (def->has_metric && def->metric > 0)
virBufferAsprintf(buf, " metric='%u'", def->metric);
- }
virBufferAddLit(buf, "/>\n");
result = 0;
const virPortGroupDef *def)
{
virBufferAsprintf(buf, "<portgroup name='%s'", def->name);
- if (def->isDefault) {
+ if (def->isDefault)
virBufferAddLit(buf, " default='yes'");
- }
if (def->trustGuestRxFilters)
virBufferAsprintf(buf, " trustGuestRxFilters='%s'",
virTristateBoolTypeToString(def->trustGuestRxFilters));
bool shortforward;
virBufferAddLit(buf, "<network");
- if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0)) {
+ if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0))
virBufferAsprintf(buf, " connections='%d'", def->connections);
- }
if (def->ipv6nogw)
virBufferAddLit(buf, " ipv6='yes'");
if (def->trustGuestRxFilters)
do {
if (virAsprintf(&newname, template, id) < 0)
return NULL;
- if (!virNetworkBridgeInUse(nets, newname, NULL)) {
+ if (!virNetworkBridgeInUse(nets, newname, NULL))
return newname;
- }
VIR_FREE(newname);
id++;