xmlXPathContextPtr ctxt,
virDomainCheckpointDiskDefPtr def)
{
- VIR_AUTOFREE(char *) checkpoint = NULL;
+ g_autofree char *checkpoint = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
size_t i;
int n;
char *tmp;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL;
if (!(def = virDomainCheckpointDefNew()))
unsigned int flags)
{
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
- VIR_AUTOFREE(char *) schema = NULL;
+ g_autofree char *schema = NULL;
if (!virXMLNodeNameEqual(root, "domaincheckpoint")) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("domaincheckpoint"));
{
int state_type;
int name_type;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) state = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *state = NULL;
if (!(name = virXMLPropString(node, "name"))) {
virReportError(VIR_ERR_CONF_SYNTAX, "%s",
{
size_t i;
int n;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(virDomainKeyWrapDefPtr) keywrap = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree virDomainKeyWrapDefPtr keywrap = NULL;
if ((n = virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0)
return n;
{
int val;
virDomainVirtioOptionsPtr res;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (*virtio || !driver)
return 0;
virBlkioDevicePtr dev)
{
xmlNodePtr node;
- VIR_AUTOFREE(char *) c = NULL;
+ g_autofree char *c = NULL;
node = root->children;
while (node) {
void *data)
{
virHashTablePtr bootHash = data;
- VIR_AUTOFREE(char *) order = NULL;
+ g_autofree char *order = NULL;
if (info->bootIndex == 0)
return 0;
virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
virDomainDeviceUSBMasterPtr master)
{
- VIR_AUTOFREE(char *) startport = NULL;
+ g_autofree char *startport = NULL;
memset(master, 0, sizeof(*master));
virDomainDeviceBootParseXML(xmlNodePtr node,
virDomainDeviceInfoPtr info)
{
- VIR_AUTOFREE(char *) order = NULL;
- VIR_AUTOFREE(char *) loadparm = NULL;
+ g_autofree char *order = NULL;
+ g_autofree char *loadparm = NULL;
if (!(order = virXMLPropString(node, "order"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virDomainDeviceISAAddressParseXML(xmlNodePtr node,
virDomainDeviceISAAddressPtr addr)
{
- VIR_AUTOFREE(char *) iobase = NULL;
- VIR_AUTOFREE(char *) irq = NULL;
+ g_autofree char *iobase = NULL;
+ g_autofree char *irq = NULL;
memset(addr, 0, sizeof(*addr));
virDomainDeviceDimmAddressParseXML(xmlNodePtr node,
virDomainDeviceDimmAddressPtr addr)
{
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!(tmp = virXMLPropString(node, "slot")) ||
virStrToLong_uip(tmp, NULL, 10, &addr->slot) < 0) {
virDomainDeviceAddressParseXML(xmlNodePtr address,
virDomainDeviceInfoPtr info)
{
- VIR_AUTOFREE(char *) type = virXMLPropString(address, "type");
+ g_autofree char *type = virXMLPropString(address, "type");
if (type) {
if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) {
xmlNodePtr boot = NULL;
xmlNodePtr rom = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) romenabled = NULL;
- VIR_AUTOFREE(char *) rombar = NULL;
- VIR_AUTOFREE(char *) aliasStr = NULL;
+ g_autofree char *romenabled = NULL;
+ g_autofree char *rombar = NULL;
+ g_autofree char *aliasStr = NULL;
virDomainDeviceInfoClear(info);
bool got_product, got_vendor;
xmlNodePtr cur;
virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb;
- VIR_AUTOFREE(char *) startupPolicy = NULL;
- VIR_AUTOFREE(char *) autoAddress = NULL;
+ g_autofree char *startupPolicy = NULL;
+ g_autofree char *autoAddress = NULL;
if ((startupPolicy = virXMLPropString(node, "startupPolicy"))) {
def->startupPolicy =
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
if (virXMLNodeNameEqual(cur, "vendor")) {
- VIR_AUTOFREE(char *) vendor = virXMLPropString(cur, "id");
+ g_autofree char *vendor = virXMLPropString(cur, "id");
if (vendor) {
got_vendor = true;
goto out;
}
} else if (virXMLNodeNameEqual(cur, "product")) {
- VIR_AUTOFREE(char *) product = virXMLPropString(cur, "id");
+ g_autofree char *product = virXMLPropString(cur, "id");
if (product) {
got_product = true;
goto out;
}
} else if (virXMLNodeNameEqual(cur, "address")) {
- VIR_AUTOFREE(char *) bus = NULL;
- VIR_AUTOFREE(char *) device = NULL;
+ g_autofree char *bus = NULL;
+ g_autofree char *device = NULL;
bus = virXMLPropString(cur, "bus");
if (bus) {
} else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) &&
virXMLNodeNameEqual(cur, "state")) {
/* Legacy back-compat. Don't add any more attributes here */
- VIR_AUTOFREE(char *) devaddr = virXMLPropString(cur, "devaddr");
+ g_autofree char *devaddr = virXMLPropString(cur, "devaddr");
if (devaddr &&
virDomainParseLegacyDeviceAddress(devaddr,
&def->info->addr.pci) < 0) {
virStorageNetHostDefPtr host)
{
int ret = -1;
- VIR_AUTOFREE(char *) transport = NULL;
- VIR_AUTOFREE(char *) port = NULL;
+ g_autofree char *transport = NULL;
+ g_autofree char *port = NULL;
memset(host, 0, sizeof(*host));
host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
bool got_address = false, got_adapter = false;
xmlNodePtr cur;
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
- VIR_AUTOFREE(char *) bus = NULL;
- VIR_AUTOFREE(char *) target = NULL;
- VIR_AUTOFREE(char *) unit = NULL;
+ g_autofree char *bus = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *unit = NULL;
cur = sourcenode->children;
while (cur != NULL) {
virDomainHostdevSubsysSCSIPtr scsisrc,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(char *) protocol = NULL;
+ g_autofree char *protocol = NULL;
if ((protocol = virXMLPropString(sourcenode, "protocol"))) {
scsisrc->protocol =
virDomainHostdevDefPtr def)
{
virDomainHostdevSubsysSCSIVHostPtr hostsrc = &def->source.subsys.u.scsi_host;
- VIR_AUTOFREE(char *) protocol = NULL;
- VIR_AUTOFREE(char *) wwpn = NULL;
+ g_autofree char *protocol = NULL;
+ g_autofree char *wwpn = NULL;
if (!(protocol = virXMLPropString(sourcenode, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
unsigned char uuid[VIR_UUID_BUFLEN] = {0};
xmlNodePtr node = NULL;
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev;
- VIR_AUTOFREE(char *) uuidxml = NULL;
+ g_autofree char *uuidxml = NULL;
if (!(node = virXPathNode("./source/address", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
virDomainHostdevSubsysSCSIPtr scsisrc = &def->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIVHostPtr scsihostsrc = &def->source.subsys.u.scsi_host;
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &def->source.subsys.u.mdev;
- VIR_AUTOFREE(char *) managed = NULL;
- VIR_AUTOFREE(char *) sgio = NULL;
- VIR_AUTOFREE(char *) rawio = NULL;
- VIR_AUTOFREE(char *) backendStr = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) display = NULL;
+ g_autofree char *managed = NULL;
+ g_autofree char *sgio = NULL;
+ g_autofree char *rawio = NULL;
+ g_autofree char *backendStr = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *display = NULL;
/* @managed can be read from the xml document - it is always an
* attribute of the toplevel element, no matter what type of
virNetDevIPAddrPtr ret = NULL;
unsigned int prefixValue = 0;
int family = AF_UNSPEC;
- VIR_AUTOFREE(virNetDevIPAddrPtr) ip = NULL;
- VIR_AUTOFREE(char *) prefixStr = NULL;
- VIR_AUTOFREE(char *) familyStr = NULL;
- VIR_AUTOFREE(char *) address = NULL;
- VIR_AUTOFREE(char *) peer = NULL;
+ g_autofree virNetDevIPAddrPtr ip = NULL;
+ g_autofree char *prefixStr = NULL;
+ g_autofree char *familyStr = NULL;
+ g_autofree char *address = NULL;
+ g_autofree char *peer = NULL;
if (!(address = virXMLPropString(node, "address"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
int nnodes;
int ret = -1;
size_t i;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(virNetDevIPAddrPtr) ip = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree virNetDevIPAddrPtr ip = NULL;
if ((nnodes = virXPathNodeSet("./ip", ctxt, &nodes)) < 0)
goto cleanup;
virNetDevCoalescePtr ret = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
unsigned long long tmp = 0;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
ctxt->node = node;
size_t i = 0, j;
int n;
virCapsHostPtr host = &caps->host;
- VIR_AUTOFREE(xmlNodePtr *) list = NULL;
+ g_autofree xmlNodePtr *list = NULL;
/* Allocate a security labels based on XML */
if ((n = virXPathNodeSet("./seclabel", ctxt, &list)) < 0)
int n;
size_t i, j;
char *model, *relabel, *label, *labelskip;
- VIR_AUTOFREE(xmlNodePtr *) list = NULL;
+ g_autofree xmlNodePtr *list = NULL;
if ((n = virXPathNodeSet("./seclabel", ctxt, &list)) < 0)
goto error;
{
virDomainLeaseDefPtr def;
xmlNodePtr cur;
- VIR_AUTOFREE(char *) lockspace = NULL;
- VIR_AUTOFREE(char *) key = NULL;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) offset = NULL;
+ g_autofree char *lockspace = NULL;
+ g_autofree char *key = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *offset = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
{
virStorageSourcePoolDefPtr source;
int ret = -1;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *mode = NULL;
*srcpool = NULL;
unsigned int flags)
{
int tlsCfgVal;
- VIR_AUTOFREE(char *) protocol = NULL;
- VIR_AUTOFREE(char *) haveTLS = NULL;
- VIR_AUTOFREE(char *) tlsCfg = NULL;
+ g_autofree char *protocol = NULL;
+ g_autofree char *haveTLS = NULL;
+ g_autofree char *tlsCfg = NULL;
if (!(protocol = virXMLPropString(node, "protocol"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr source;
VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) format = NULL;
- VIR_AUTOFREE(char *) idx = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *format = NULL;
+ g_autofree char *idx = NULL;
if (!(ctxt->node = virXPathNode("./backingStore", ctxt)))
return 0;
{
xmlNodePtr mirrorNode;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) mirrorFormat = NULL;
- VIR_AUTOFREE(char *) mirrorType = NULL;
- VIR_AUTOFREE(char *) ready = NULL;
- VIR_AUTOFREE(char *) blockJob = NULL;
- VIR_AUTOFREE(char *) index = NULL;
+ g_autofree char *mirrorFormat = NULL;
+ g_autofree char *mirrorType = NULL;
+ g_autofree char *ready = NULL;
+ g_autofree char *blockJob = NULL;
+ g_autofree char *index = NULL;
ctxt->node = cur;
virDomainDiskDefGeometryParse(virDomainDiskDefPtr def,
xmlNodePtr cur)
{
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if ((tmp = virXMLPropString(cur, "cyls"))) {
if (virStrToLong_ui(tmp, NULL, 10, &def->geometry.cylinders) < 0) {
virDomainDiskDefDriverParseXML(virDomainDiskDefPtr def,
xmlNodePtr cur)
{
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
def->driverName = virXMLPropString(cur, "name");
bool source = false;
virStorageEncryptionPtr encryption = NULL;
VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(char *) snapshot = NULL;
- VIR_AUTOFREE(char *) rawio = NULL;
- VIR_AUTOFREE(char *) sgio = NULL;
- VIR_AUTOFREE(char *) target = NULL;
- VIR_AUTOFREE(char *) bus = NULL;
- VIR_AUTOFREE(char *) devaddr = NULL;
- VIR_AUTOFREE(char *) serial = NULL;
- VIR_AUTOFREE(char *) startupPolicy = NULL;
- VIR_AUTOFREE(char *) tray = NULL;
- VIR_AUTOFREE(char *) removable = NULL;
- VIR_AUTOFREE(char *) logical_block_size = NULL;
- VIR_AUTOFREE(char *) physical_block_size = NULL;
- VIR_AUTOFREE(char *) wwn = NULL;
- VIR_AUTOFREE(char *) vendor = NULL;
- VIR_AUTOFREE(char *) product = NULL;
- VIR_AUTOFREE(char *) domain_name = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree char *snapshot = NULL;
+ g_autofree char *rawio = NULL;
+ g_autofree char *sgio = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *bus = NULL;
+ g_autofree char *devaddr = NULL;
+ g_autofree char *serial = NULL;
+ g_autofree char *startupPolicy = NULL;
+ g_autofree char *tray = NULL;
+ g_autofree char *removable = NULL;
+ g_autofree char *logical_block_size = NULL;
+ g_autofree char *physical_block_size = NULL;
+ g_autofree char *wwn = NULL;
+ g_autofree char *vendor = NULL;
+ g_autofree char *product = NULL;
+ g_autofree char *domain_name = NULL;
if (!(def = virDomainDiskDefNew(xmlopt)))
return NULL;
bool required)
{
unsigned long long bytes;
- VIR_AUTOFREE(char *) xpath_full = NULL;
- VIR_AUTOFREE(char *) unit = NULL;
- VIR_AUTOFREE(char *) bytes_str = NULL;
+ g_autofree char *xpath_full = NULL;
+ g_autofree char *unit = NULL;
+ g_autofree char *bytes_str = NULL;
*val = 0;
if (virAsprintf(&xpath_full, "string(%s)", xpath) < 0)
int ports = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
int rc;
- VIR_AUTOFREE(char *) typeStr = NULL;
- VIR_AUTOFREE(char *) idx = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) queues = NULL;
- VIR_AUTOFREE(char *) cmd_per_lun = NULL;
- VIR_AUTOFREE(char *) max_sectors = NULL;
- VIR_AUTOFREE(char *) modelName = NULL;
- VIR_AUTOFREE(char *) chassisNr = NULL;
- VIR_AUTOFREE(char *) chassis = NULL;
- VIR_AUTOFREE(char *) port = NULL;
- VIR_AUTOFREE(char *) busNr = NULL;
- VIR_AUTOFREE(char *) targetIndex = NULL;
- VIR_AUTOFREE(char *) ioeventfd = NULL;
- VIR_AUTOFREE(char *) portsStr = NULL;
- VIR_AUTOFREE(char *) iothread = NULL;
+ g_autofree char *typeStr = NULL;
+ g_autofree char *idx = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *queues = NULL;
+ g_autofree char *cmd_per_lun = NULL;
+ g_autofree char *max_sectors = NULL;
+ g_autofree char *modelName = NULL;
+ g_autofree char *chassisNr = NULL;
+ g_autofree char *chassis = NULL;
+ g_autofree char *port = NULL;
+ g_autofree char *busNr = NULL;
+ g_autofree char *targetIndex = NULL;
+ g_autofree char *ioeventfd = NULL;
+ g_autofree char *portsStr = NULL;
+ g_autofree char *iothread = NULL;
ctxt->node = node;
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
- VIR_AUTOFREE(char *) vectors = virXMLPropString(node, "vectors");
+ g_autofree char *vectors = virXMLPropString(node, "vectors");
def->opts.vioserial.ports = ports;
if (vectors) {
}
break;
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
- VIR_AUTOFREE(char *) gntframes = virXMLPropString(node, "maxGrantFrames");
+ g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames");
if (gntframes) {
int r = virStrToLong_i(gntframes, NULL, 10,
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainFSDefPtr def;
xmlNodePtr cur;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) fsdriver = NULL;
- VIR_AUTOFREE(char *) source = NULL;
- VIR_AUTOFREE(char *) target = NULL;
- VIR_AUTOFREE(char *) format = NULL;
- VIR_AUTOFREE(char *) accessmode = NULL;
- VIR_AUTOFREE(char *) wrpolicy = NULL;
- VIR_AUTOFREE(char *) usage = NULL;
- VIR_AUTOFREE(char *) units = NULL;
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *fsdriver = NULL;
+ g_autofree char *source = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *format = NULL;
+ g_autofree char *accessmode = NULL;
+ g_autofree char *wrpolicy = NULL;
+ g_autofree char *usage = NULL;
+ g_autofree char *units = NULL;
+ g_autofree char *model = NULL;
ctxt->node = node;
xmlNodePtr bandwidth_node = NULL;
xmlNodePtr vlanNode;
xmlNodePtr virtPortNode;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
- VIR_AUTOFREE(char *) addrtype = NULL;
- VIR_AUTOFREE(char *) trustGuestRxFilters = NULL;
- VIR_AUTOFREE(char *) macTableManager = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *mode = NULL;
+ g_autofree char *addrtype = NULL;
+ g_autofree char *trustGuestRxFilters = NULL;
+ g_autofree char *macTableManager = NULL;
if (VIR_ALLOC(actual) < 0)
return -1;
}
} else if (actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
- VIR_AUTOFREE(char *) class_id = NULL;
+ g_autofree char *class_id = NULL;
xmlNodePtr sourceNode;
class_id = virXPathString("string(./class/@id)", ctxt);
int tmpVal;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr cur;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
ctxt->node = node;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainChrSourceReconnectDef reconnect = {0};
int rv, val;
- VIR_AUTOFREE(char *) macaddr = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) network = NULL;
- VIR_AUTOFREE(char *) portgroup = NULL;
- VIR_AUTOFREE(char *) portid = NULL;
- VIR_AUTOFREE(char *) bridge = NULL;
- VIR_AUTOFREE(char *) dev = NULL;
- VIR_AUTOFREE(char *) ifname = NULL;
- VIR_AUTOFREE(char *) managed_tap = NULL;
- VIR_AUTOFREE(char *) ifname_guest = NULL;
- VIR_AUTOFREE(char *) ifname_guest_actual = NULL;
- VIR_AUTOFREE(char *) script = NULL;
- VIR_AUTOFREE(char *) address = NULL;
- VIR_AUTOFREE(char *) port = NULL;
- VIR_AUTOFREE(char *) localaddr = NULL;
- VIR_AUTOFREE(char *) localport = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) backend = NULL;
- VIR_AUTOFREE(char *) txmode = NULL;
- VIR_AUTOFREE(char *) ioeventfd = NULL;
- VIR_AUTOFREE(char *) event_idx = NULL;
- VIR_AUTOFREE(char *) queues = NULL;
- VIR_AUTOFREE(char *) rx_queue_size = NULL;
- VIR_AUTOFREE(char *) tx_queue_size = NULL;
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) filter = NULL;
- VIR_AUTOFREE(char *) internal = NULL;
- VIR_AUTOFREE(char *) devaddr = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
- VIR_AUTOFREE(char *) linkstate = NULL;
- VIR_AUTOFREE(char *) addrtype = NULL;
- VIR_AUTOFREE(char *) domain_name = NULL;
- VIR_AUTOFREE(char *) vhostuser_mode = NULL;
- VIR_AUTOFREE(char *) vhostuser_path = NULL;
- VIR_AUTOFREE(char *) vhostuser_type = NULL;
- VIR_AUTOFREE(char *) trustGuestRxFilters = NULL;
- VIR_AUTOFREE(char *) vhost_path = NULL;
+ g_autofree char *macaddr = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *network = NULL;
+ g_autofree char *portgroup = NULL;
+ g_autofree char *portid = NULL;
+ g_autofree char *bridge = NULL;
+ g_autofree char *dev = NULL;
+ g_autofree char *ifname = NULL;
+ g_autofree char *managed_tap = NULL;
+ g_autofree char *ifname_guest = NULL;
+ g_autofree char *ifname_guest_actual = NULL;
+ g_autofree char *script = NULL;
+ g_autofree char *address = NULL;
+ g_autofree char *port = NULL;
+ g_autofree char *localaddr = NULL;
+ g_autofree char *localport = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *backend = NULL;
+ g_autofree char *txmode = NULL;
+ g_autofree char *ioeventfd = NULL;
+ g_autofree char *event_idx = NULL;
+ g_autofree char *queues = NULL;
+ g_autofree char *rx_queue_size = NULL;
+ g_autofree char *tx_queue_size = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *filter = NULL;
+ g_autofree char *internal = NULL;
+ g_autofree char *devaddr = NULL;
+ g_autofree char *mode = NULL;
+ g_autofree char *linkstate = NULL;
+ g_autofree char *addrtype = NULL;
+ g_autofree char *domain_name = NULL;
+ g_autofree char *vhostuser_mode = NULL;
+ g_autofree char *vhostuser_path = NULL;
+ g_autofree char *vhostuser_type = NULL;
+ g_autofree char *trustGuestRxFilters = NULL;
+ g_autofree char *vhost_path = NULL;
if (!(def = virDomainNetDefNew(xmlopt)))
return NULL;
{
xmlNodePtr child;
unsigned int port;
- VIR_AUTOFREE(char *) targetType = virXMLPropString(cur, "type");
- VIR_AUTOFREE(char *) targetModel = NULL;
- VIR_AUTOFREE(char *) addrStr = NULL;
- VIR_AUTOFREE(char *) portStr = NULL;
- VIR_AUTOFREE(char *) stateStr = NULL;
+ g_autofree char *targetType = virXMLPropString(cur, "type");
+ g_autofree char *targetModel = NULL;
+ g_autofree char *addrStr = NULL;
+ g_autofree char *portStr = NULL;
+ g_autofree char *stateStr = NULL;
if ((def->targetType =
virDomainChrTargetTypeFromString(def->deviceType,
static int
virDomainChrSourceDefParseMode(xmlNodePtr source)
{
- VIR_AUTOFREE(char *) mode = virXMLPropString(source, "mode");
+ g_autofree char *mode = virXMLPropString(source, "mode");
if (!mode || STREQ(mode, "connect")) {
return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
{
int mode;
int tmpVal;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if ((mode = virDomainChrSourceDefParseMode(source)) < 0)
return -1;
virDomainChrSourceDefParseFile(virDomainChrSourceDefPtr def,
xmlNodePtr source)
{
- VIR_AUTOFREE(char *) append = NULL;
+ g_autofree char *append = NULL;
def->data.file.path = virXMLPropString(source, "path");
virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def,
xmlNodePtr protocol)
{
- VIR_AUTOFREE(char *) prot = NULL;
+ g_autofree char *prot = NULL;
if (def->type != VIR_DOMAIN_CHR_TYPE_TCP)
return 0;
virDomainChrSourceDefParseLog(virDomainChrSourceDefPtr def,
xmlNodePtr log)
{
- VIR_AUTOFREE(char *) append = NULL;
+ g_autofree char *append = NULL;
def->logfile = virXMLPropString(log, "file");
const char *nodeName;
virDomainChrDefPtr def;
bool seenTarget = false;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (!(def = virDomainChrDefNew(xmlopt)))
return NULL;
xmlNodePtr cur;
virDomainSmartcardDefPtr def;
size_t i;
- VIR_AUTOFREE(char *) mode = NULL;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *mode = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
virDomainTPMDefPtr def;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
int nbackends;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) backend = NULL;
- VIR_AUTOFREE(char *) version = NULL;
- VIR_AUTOFREE(char *) secretuuid = NULL;
- VIR_AUTOFREE(xmlNodePtr *) backends = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *backend = NULL;
+ g_autofree char *version = NULL;
+ g_autofree char *secretuuid = NULL;
+ g_autofree xmlNodePtr *backends = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
unsigned int flags)
{
virDomainPanicDefPtr panic;
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *model = NULL;
if (VIR_ALLOC(panic) < 0)
return NULL;
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainInputDefPtr def;
- VIR_AUTOFREE(char *) evdev = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) bus = NULL;
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *evdev = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *bus = NULL;
+ g_autofree char *model = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
unsigned int flags)
{
virDomainHubDefPtr def;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr catchup;
int ret;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) present = NULL;
- VIR_AUTOFREE(char *) tickpolicy = NULL;
- VIR_AUTOFREE(char *) track = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *present = NULL;
+ g_autofree char *tickpolicy = NULL;
+ g_autofree char *track = NULL;
+ g_autofree char *mode = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
virDomainGraphicsAuthDefPtr def,
int type)
{
- VIR_AUTOFREE(char *) validTo = NULL;
- VIR_AUTOFREE(char *) connected = virXMLPropString(node, "connected");
+ g_autofree char *validTo = NULL;
+ g_autofree char *connected = virXMLPropString(node, "connected");
def->passwd = virXMLPropString(node, "passwd");
int ret = -1;
const char *graphicsType = virDomainGraphicsTypeToString(graphics->type);
int tmp, typeVal;
- VIR_AUTOFREE(char *) type = virXMLPropString(node, "type");
- VIR_AUTOFREE(char *) address = virXMLPropString(node, "address");
- VIR_AUTOFREE(char *) network = virXMLPropString(node, "network");
- VIR_AUTOFREE(char *) socketPath = virXMLPropString(node, "socket");
- VIR_AUTOFREE(char *) fromConfig = virXMLPropString(node, "fromConfig");
- VIR_AUTOFREE(char *) autoGenerated = virXMLPropString(node, "autoGenerated");
- VIR_AUTOFREE(char *) addressCompat = NULL;
- VIR_AUTOFREE(char *) socketCompat = NULL;
+ g_autofree char *type = virXMLPropString(node, "type");
+ g_autofree char *address = virXMLPropString(node, "address");
+ g_autofree char *network = virXMLPropString(node, "network");
+ g_autofree char *socketPath = virXMLPropString(node, "socket");
+ g_autofree char *fromConfig = virXMLPropString(node, "fromConfig");
+ g_autofree char *autoGenerated = virXMLPropString(node, "autoGenerated");
+ g_autofree char *addressCompat = NULL;
+ g_autofree char *socketCompat = NULL;
if (parent) {
addressCompat = virXMLPropString(parent, "listen");
virDomainGraphicsListenDef newListen = {0};
int nListens;
int ret = -1;
- VIR_AUTOFREE(xmlNodePtr *) listenNodes = NULL;
- VIR_AUTOFREE(char *) socketPath = NULL;
+ g_autofree xmlNodePtr *listenNodes = NULL;
+ g_autofree char *socketPath = NULL;
ctxt->node = node;
xmlXPathContextPtr ctxt,
unsigned int flags)
{
- VIR_AUTOFREE(char *) port = virXMLPropString(node, "port");
- VIR_AUTOFREE(char *) websocket = virXMLPropString(node, "websocket");
- VIR_AUTOFREE(char *) websocketGenerated = virXMLPropString(node, "websocketGenerated");
- VIR_AUTOFREE(char *) sharePolicy = virXMLPropString(node, "sharePolicy");
- VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport");
+ g_autofree char *port = virXMLPropString(node, "port");
+ g_autofree char *websocket = virXMLPropString(node, "websocket");
+ g_autofree char *websocketGenerated = virXMLPropString(node, "websocketGenerated");
+ g_autofree char *sharePolicy = virXMLPropString(node, "sharePolicy");
+ g_autofree char *autoport = virXMLPropString(node, "autoport");
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
return -1;
int enableVal;
xmlNodePtr glNode;
int ret = -1;
- VIR_AUTOFREE(char *) fullscreen = virXMLPropString(node, "fullscreen");
- VIR_AUTOFREE(char *) enable = NULL;
+ g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
+ g_autofree char *enable = NULL;
ctxt->node = node;
xmlXPathContextPtr ctxt,
unsigned int flags)
{
- VIR_AUTOFREE(char *) port = virXMLPropString(node, "port");
- VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport");
- VIR_AUTOFREE(char *) replaceUser = virXMLPropString(node, "replaceUser");
- VIR_AUTOFREE(char *) multiUser = virXMLPropString(node, "multiUser");
+ g_autofree char *port = virXMLPropString(node, "port");
+ g_autofree char *autoport = virXMLPropString(node, "autoport");
+ g_autofree char *replaceUser = virXMLPropString(node, "replaceUser");
+ g_autofree char *multiUser = virXMLPropString(node, "multiUser");
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
return -1;
virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
xmlNodePtr node)
{
- VIR_AUTOFREE(char *) fullscreen = virXMLPropString(node, "fullscreen");
+ g_autofree char *fullscreen = virXMLPropString(node, "fullscreen");
if (fullscreen != NULL) {
if (virStringParseYesNo(fullscreen, &def->data.desktop.fullscreen) < 0) {
{
xmlNodePtr cur;
int defaultModeVal;
- VIR_AUTOFREE(char *) port = virXMLPropString(node, "port");
- VIR_AUTOFREE(char *) tlsPort = virXMLPropString(node, "tlsPort");
- VIR_AUTOFREE(char *) autoport = virXMLPropString(node, "autoport");
- VIR_AUTOFREE(char *) defaultMode = virXMLPropString(node, "defaultMode");
+ g_autofree char *port = virXMLPropString(node, "port");
+ g_autofree char *tlsPort = virXMLPropString(node, "tlsPort");
+ g_autofree char *autoport = virXMLPropString(node, "autoport");
+ g_autofree char *defaultMode = virXMLPropString(node, "defaultMode");
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
return -1;
if (cur->type == XML_ELEMENT_NODE) {
if (virXMLNodeNameEqual(cur, "channel")) {
int nameval, modeval;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *mode = NULL;
name = virXMLPropString(cur, "name");
mode = virXMLPropString(cur, "mode");
def->data.spice.channels[nameval] = modeval;
} else if (virXMLNodeNameEqual(cur, "image")) {
int compressionVal;
- VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression");
+ g_autofree char *compression = virXMLPropString(cur, "compression");
if (!compression) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
def->data.spice.image = compressionVal;
} else if (virXMLNodeNameEqual(cur, "jpeg")) {
int compressionVal;
- VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression");
+ g_autofree char *compression = virXMLPropString(cur, "compression");
if (!compression) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
def->data.spice.jpeg = compressionVal;
} else if (virXMLNodeNameEqual(cur, "zlib")) {
int compressionVal;
- VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression");
+ g_autofree char *compression = virXMLPropString(cur, "compression");
if (!compression) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
def->data.spice.zlib = compressionVal;
} else if (virXMLNodeNameEqual(cur, "playback")) {
int compressionVal;
- VIR_AUTOFREE(char *) compression = virXMLPropString(cur, "compression");
+ g_autofree char *compression = virXMLPropString(cur, "compression");
if (!compression) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
def->data.spice.playback = compressionVal;
} else if (virXMLNodeNameEqual(cur, "streaming")) {
int modeVal;
- VIR_AUTOFREE(char *) mode = virXMLPropString(cur, "mode");
+ g_autofree char *mode = virXMLPropString(cur, "mode");
if (!mode) {
virReportError(VIR_ERR_XML_ERROR, "%s",
def->data.spice.streaming = modeVal;
} else if (virXMLNodeNameEqual(cur, "clipboard")) {
int copypasteVal;
- VIR_AUTOFREE(char *) copypaste = virXMLPropString(cur, "copypaste");
+ g_autofree char *copypaste = virXMLPropString(cur, "copypaste");
if (!copypaste) {
virReportError(VIR_ERR_XML_ERROR, "%s",
def->data.spice.copypaste = copypasteVal;
} else if (virXMLNodeNameEqual(cur, "filetransfer")) {
int enableVal;
- VIR_AUTOFREE(char *) enable = virXMLPropString(cur, "enable");
+ g_autofree char *enable = virXMLPropString(cur, "enable");
if (!enable) {
virReportError(VIR_ERR_XML_ERROR, "%s",
def->data.spice.filetransfer = enableVal;
} else if (virXMLNodeNameEqual(cur, "gl")) {
int enableVal;
- VIR_AUTOFREE(char *) enable = virXMLPropString(cur, "enable");
- VIR_AUTOFREE(char *) rendernode = virXMLPropString(cur, "rendernode");
+ g_autofree char *enable = virXMLPropString(cur, "enable");
+ g_autofree char *rendernode = virXMLPropString(cur, "rendernode");
if (!enable) {
virReportError(VIR_ERR_XML_ERROR, "%s",
} else if (virXMLNodeNameEqual(cur, "mouse")) {
int modeVal;
- VIR_AUTOFREE(char *) mode = virXMLPropString(cur, "mode");
+ g_autofree char *mode = virXMLPropString(cur, "mode");
if (!mode) {
virReportError(VIR_ERR_XML_ERROR, "%s",
{
virDomainGraphicsDefPtr def;
int typeVal;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (!(def = virDomainGraphicsDefNew(xmlopt)))
return NULL;
virDomainSoundCodecDefParseXML(xmlNodePtr node)
{
virDomainSoundCodecDefPtr def;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
{
virDomainSoundDefPtr def;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *model = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
def->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
int ncodecs;
- VIR_AUTOFREE(xmlNodePtr *) codecNodes = NULL;
+ g_autofree xmlNodePtr *codecNodes = NULL;
/* parse the <codec> subelements for sound models that support it */
ncodecs = virXPathNodeSet("./codec", ctxt, &codecNodes);
unsigned int flags)
{
virDomainWatchdogDefPtr def;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) action = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *action = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
virDomainRNGDefPtr def;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
int nbackends;
- VIR_AUTOFREE(xmlNodePtr *) backends = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) backend = NULL;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree xmlNodePtr *backends = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *backend = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
virDomainMemballoonDefPtr def;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
unsigned int period = 0;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) deflate = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *deflate = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
xmlNodePtr msi = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr server = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
int ret = -1;
virSysinfoSystemDefPtr def;
- VIR_AUTOFREE(char *) tmpUUID = NULL;
+ g_autofree char *tmpUUID = NULL;
ctxt->node = node;
size_t i, nboards = 0;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
int n;
- VIR_AUTOFREE(virSysinfoBaseBoardDefPtr) boards = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree virSysinfoBaseBoardDefPtr boards = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if ((n = virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0)
return ret;
virSysinfoOEMStringsDefPtr def;
int nstrings;
size_t i;
- VIR_AUTOFREE(xmlNodePtr *) strings = NULL;
+ g_autofree xmlNodePtr *strings = NULL;
ctxt->node = node;
{
virSysinfoDefPtr def;
xmlNodePtr tmpnode;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (!virXMLNodeNameEqual(node, "sysinfo")) {
virReportError(VIR_ERR_XML_ERROR, "%s",
xmlNodePtr cur;
virDomainVideoAccelDefPtr def;
int val;
- VIR_AUTOFREE(char *) accel2d = NULL;
- VIR_AUTOFREE(char *) accel3d = NULL;
- VIR_AUTOFREE(char *) rendernode = NULL;
+ g_autofree char *accel2d = NULL;
+ g_autofree char *accel3d = NULL;
+ g_autofree char *rendernode = NULL;
cur = node->children;
while (cur != NULL) {
xmlNodePtr cur;
virDomainVideoDriverDefPtr def;
int val;
- VIR_AUTOFREE(char *) vgaconf = NULL;
+ g_autofree char *vgaconf = NULL;
cur = node->children;
while (cur != NULL) {
virDomainVideoDefPtr def;
xmlNodePtr cur;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) driver_name = NULL;
- VIR_AUTOFREE(char *) heads = NULL;
- VIR_AUTOFREE(char *) vram = NULL;
- VIR_AUTOFREE(char *) vram64 = NULL;
- VIR_AUTOFREE(char *) ram = NULL;
- VIR_AUTOFREE(char *) vgamem = NULL;
- VIR_AUTOFREE(char *) primary = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *driver_name = NULL;
+ g_autofree char *heads = NULL;
+ g_autofree char *vram = NULL;
+ g_autofree char *vram64 = NULL;
+ g_autofree char *ram = NULL;
+ g_autofree char *vgamem = NULL;
+ g_autofree char *primary = NULL;
if (!(def = virDomainVideoDefNew(xmlopt)))
return NULL;
{
virDomainHostdevDefPtr def;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) mode = virXMLPropString(node, "mode");
- VIR_AUTOFREE(char *) type = virXMLPropString(node, "type");
+ g_autofree char *mode = virXMLPropString(node, "mode");
+ g_autofree char *type = virXMLPropString(node, "type");
ctxt->node = node;
{
xmlNodePtr cur;
virDomainRedirdevDefPtr def;
- VIR_AUTOFREE(char *) bus = NULL;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *bus = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
{
virDomainRedirFilterUSBDevDefPtr def;
- VIR_AUTOFREE(char *) class = NULL;
- VIR_AUTOFREE(char *) vendor = NULL;
- VIR_AUTOFREE(char *) product = NULL;
- VIR_AUTOFREE(char *) version = NULL;
- VIR_AUTOFREE(char *) allow = NULL;
+ g_autofree char *class = NULL;
+ g_autofree char *vendor = NULL;
+ g_autofree char *product = NULL;
+ g_autofree char *version = NULL;
+ g_autofree char *allow = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
size_t i;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainRedirFilterDefPtr def = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if (VIR_ALLOC(def) < 0)
goto error;
int defaultVal,
virEventActionFromStringFunc convFunc)
{
- VIR_AUTOFREE(char *) tmp = virXPathString(xpath, ctxt);
+ g_autofree char *tmp = virXPathString(xpath, ctxt);
if (tmp == NULL) {
*val = defaultVal;
const char *xpath,
int *val)
{
- VIR_AUTOFREE(char *) tmp = virXPathString(xpath, ctxt);
+ g_autofree char *tmp = virXPathString(xpath, ctxt);
if (tmp) {
*val = virTristateBoolTypeFromString(tmp);
xmlNodePtr node)
{
int event;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) enabled = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *enabled = NULL;
if (!(name = virXMLPropString(node, "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing perf event name"));
{
size_t i;
int n;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if ((n = virXPathNodeSet("./perf/event", ctxt, &nodes)) < 0)
return n;
int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
ctxt->node = node;
- VIR_AUTOFREE(char *) nodemask = NULL;
+ g_autofree char *nodemask = NULL;
switch ((virDomainMemoryModel) def->model) {
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainSEVDefPtr def;
unsigned long policy;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
xmlNodePtr node;
virDomainMemoryDefPtr def;
int val;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr driver;
int val;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(virDomainIOMMUDefPtr) iommu = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree virDomainIOMMUDefPtr iommu = NULL;
ctxt->node = node;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
xmlNodePtr cid;
int val;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(virDomainVsockDefPtr) vsock = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree virDomainVsockDefPtr vsock = NULL;
ctxt->node = node;
VIR_AUTOPTR(xmlDoc) xml = NULL;
xmlNodePtr node;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
- VIR_AUTOFREE(virDomainDeviceDefPtr) dev = NULL;
+ g_autofree virDomainDeviceDefPtr dev = NULL;
char *netprefix;
if (!(xml = virXMLParseStringCtxt(xmlStr, _("(device_definition)"), &ctxt)))
virCapsPtr caps)
{
char *retemu;
- VIR_AUTOFREE(virCapsDomainDataPtr) capsdata = NULL;
+ g_autofree virCapsDomainDataPtr capsdata = NULL;
if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
def->os.arch, def->virtType, NULL, NULL)))
xmlNodePtr node;
size_t i;
int n;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
/* analysis of the boot devices */
if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0)
virDomainIOThreadIDDefParseXML(xmlNodePtr node)
{
virDomainIOThreadIDDefPtr iothrid;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (VIR_ALLOC(iothrid) < 0)
return NULL;
size_t i;
int n = 0;
unsigned int iothreads = 0;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
tmp = virXPathString("string(./iothreads[1])", ctxt);
if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) {
{
virDomainVcpuDefPtr vcpu;
unsigned int vcpuid;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!(tmp = virXMLPropString(node, "vcpu"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("missing vcpu id in vcpupin"));
{
virDomainIOThreadIDDefPtr iothrid;
unsigned int iothreadid;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
VIR_AUTOPTR(virBitmap) cpumask = NULL;
if (!(tmp = virXMLPropString(node, "iothread"))) {
virDomainEmulatorPinDefParseXML(xmlNodePtr node)
{
virBitmapPtr ret = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
VIR_AUTOPTR(virBitmap) def = NULL;
if (!(tmp = virXMLPropString(node, "cpuset"))) {
{
int ret = -1;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) nodeset = NULL;
+ g_autofree char *nodeset = NULL;
ctxt->node = node;
virDomainLoaderDefPtr loader,
bool fwAutoSelect)
{
- VIR_AUTOFREE(char *) readonly_str = NULL;
- VIR_AUTOFREE(char *) secure_str = NULL;
- VIR_AUTOFREE(char *) type_str = NULL;
+ g_autofree char *readonly_str = NULL;
+ g_autofree char *secure_str = NULL;
+ g_autofree char *type_str = NULL;
secure_str = virXMLPropString(node, "secure");
int *priority)
{
int pol = 0;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!(tmp = virXMLPropString(node, "scheduler"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virDomainEmulatorSchedParse(xmlNodePtr node,
virDomainDefPtr def)
{
- VIR_AUTOFREE(virDomainThreadSchedParamPtr) sched = NULL;
+ g_autofree virDomainThreadSchedParamPtr sched = NULL;
if (VIR_ALLOC(sched) < 0)
return -1;
int *priority)
{
virBitmapPtr ret = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!(tmp = virXMLPropString(node, name))) {
virReportError(VIR_ERR_XML_ERROR,
size_t i;
unsigned int maxvcpus;
unsigned int vcpus;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
vcpus = maxvcpus = 1;
char *name = NULL;
size_t i;
int n;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree char *tmp = NULL;
/*
* Booting options for different OS types....
def->os.type == VIR_DOMAIN_OSTYPE_XENPVH ||
def->os.type == VIR_DOMAIN_OSTYPE_HVM ||
def->os.type == VIR_DOMAIN_OSTYPE_UML) {
- VIR_AUTOFREE(char *) firmware = NULL;
+ g_autofree char *firmware = NULL;
xmlNodePtr loader_node;
def->os.kernel = virXPathString("string(./os/kernel[1])", ctxt);
xmlNodePtr node,
virBitmapPtr *vcpus)
{
- VIR_AUTOFREE(char *) vcpus_str = NULL;
+ g_autofree char *vcpus_str = NULL;
vcpus_str = virXMLPropString(node, "vcpus");
if (!vcpus_str) {
int type;
unsigned long long size;
int ret = -1;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
ctxt->node = node;
int n = 0;
int rv = -1;
int ret = -1;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(char *) id = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree char *id = NULL;
ctxt->node = node;
{
virDomainResctrlDefPtr resctrl = NULL;
virDomainResctrlDefPtr ret = NULL;
- VIR_AUTOFREE(char *) vcpus_str = NULL;
- VIR_AUTOFREE(char *) alloc_id = NULL;
+ g_autofree char *vcpus_str = NULL;
+ g_autofree char *alloc_id = NULL;
/* We need to format it back because we need to be consistent in the naming
* even when users specify some "sub-optimal" string there. */
int n;
int ret = -1;
VIR_AUTOPTR(virBitmap) vcpus = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
ctxt->node = node;
virCapsPtr caps,
unsigned int flags)
{
- VIR_AUTOFREE(char *) virttype = NULL;
- VIR_AUTOFREE(char *) arch = NULL;
- VIR_AUTOFREE(char *) ostype = NULL;
- VIR_AUTOFREE(virCapsDomainDataPtr) capsdata = NULL;
+ g_autofree char *virttype = NULL;
+ g_autofree char *arch = NULL;
+ g_autofree char *ostype = NULL;
+ g_autofree virCapsDomainDataPtr capsdata = NULL;
virttype = virXPathString("string(./@type)", ctxt);
ostype = virXPathString("string(./os/type[1])", ctxt);
unsigned int id;
unsigned int bandwidth;
int ret = -1;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
ctxt->node = node;
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainResctrlDefPtr resctrl = NULL;
VIR_AUTOPTR(virBitmap) vcpus = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
ssize_t i = 0;
int n;
bool usb_other = false;
bool usb_master = false;
char *netprefix = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree char *tmp = NULL;
if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) {
- VIR_AUTOFREE(char *) schema = NULL;
+ g_autofree char *schema = NULL;
schema = virFileFindResource("domain.rng",
abs_top_srcdir "/docs/schemas",
int state;
int reason = 0;
void *parseOpaque = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if (!(obj = virDomainObjNew(xmlopt)))
return NULL;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
if (memcmp(src->target.addr, dst->target.addr,
sizeof(*src->target.addr)) != 0) {
- VIR_AUTOFREE(char *) saddr = virSocketAddrFormatFull(src->target.addr, true, ":");
- VIR_AUTOFREE(char *) daddr = virSocketAddrFormatFull(dst->target.addr, true, ":");
+ g_autofree char *saddr = virSocketAddrFormatFull(src->target.addr, true, ":");
+ g_autofree char *daddr = virSocketAddrFormatFull(dst->target.addr, true, ":");
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target channel addr %s does not match source %s"),
NULLSTR(daddr), NULLSTR(saddr));
{
size_t i;
virErrorPtr err;
- VIR_AUTOFREE(char *) strSrc = NULL;
- VIR_AUTOFREE(char *) strDst = NULL;
+ g_autofree char *strSrc = NULL;
+ g_autofree char *strDst = NULL;
if (src->virtType != dst->virtType) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
unsigned int flags)
{
size_t n;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
virBufferAsprintf(attrBuf, " protocol='%s'",
virStorageNetProtocolTypeToString(src->protocol));
virDomainNetGetModelString(def));
if (virDomainNetIsVirtioModel(def)) {
int rc = 0;
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) gueststr = NULL;
- VIR_AUTOFREE(char *) hoststr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *gueststr = NULL;
+ g_autofree char *hoststr = NULL;
if (virDomainVirtioNetDriverFormat(&str, def) < 0 ||
virDomainVirtioNetGuestOptsFormat(&gueststr, def) < 0 ||
switch (def->targetType) {
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: {
int port = virSocketAddrGetPort(def->target.addr);
- VIR_AUTOFREE(char *) addr = NULL;
+ g_autofree char *addr = NULL;
if (port < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to format guestfwd port"));
virDomainMemorySourceDefFormat(virBufferPtr buf,
virDomainMemoryDefPtr def)
{
- VIR_AUTOFREE(char *) bitmap = NULL;
+ g_autofree char *bitmap = NULL;
if (!def->pagesize && !def->sourceNodes && !def->nvdimmPath)
return 0;
hugepage->size);
if (hugepage->nodemask) {
- VIR_AUTOFREE(char *) nodeset = NULL;
+ g_autofree char *nodeset = NULL;
if (!(nodeset = virBitmapFormat(hugepage->nodemask)))
return -1;
virBufferAsprintf(buf, " nodeset='%s'", nodeset);
virResctrlMonitorType tag,
virBufferPtr buf)
{
- VIR_AUTOFREE(char *) vcpus = NULL;
+ g_autofree char *vcpus = NULL;
if (domresmon->tag != tag)
return 0;
g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
size_t i = 0;
int ret = -1;
- VIR_AUTOFREE(char *) vcpus = NULL;
+ g_autofree char *vcpus = NULL;
virBufferSetChildIndent(&childrenBuf, buf);
if (virResctrlAllocForeachCache(resctrl->alloc,
{
g_auto(virBuffer) childrenBuf = VIR_BUFFER_INITIALIZER;
int ret = -1;
- VIR_AUTOFREE(char *) vcpus = NULL;
+ g_autofree char *vcpus = NULL;
virBufferSetChildIndent(&childrenBuf, buf);
if (virResctrlAllocForeachMemory(resctrl->alloc,
{
virDomainVcpuDefPtr vcpu;
size_t i;
- VIR_AUTOFREE(char *) cpumask = NULL;
+ g_autofree char *cpumask = NULL;
virBufferAddLit(buf, "<vcpu");
virBufferAsprintf(buf, " placement='%s'",
const char *xml)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- VIR_AUTOFREE(char *) configFile = NULL;
+ g_autofree char *configFile = NULL;
if (!configDir)
return 0;
virCapsPtr caps,
virDomainDefPtr def)
{
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
if (!(xml = virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECURE)))
return -1;
VIR_DOMAIN_DEF_FORMAT_PCI_ORIG_STATES |
VIR_DOMAIN_DEF_FORMAT_CLOCK_ADJUST);
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
if (!(xml = virDomainObjFormat(xmlopt, obj, caps, flags)))
return -1;
const char *autostartDir,
virDomainObjPtr dom)
{
- VIR_AUTOFREE(char *) configFile = NULL;
- VIR_AUTOFREE(char *) autostartLink = NULL;
+ g_autofree char *configFile = NULL;
+ g_autofree char *autostartLink = NULL;
if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL)
return -1;
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
if (migratable)
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE;
int rc = -1;
char *netprefix;
- VIR_AUTOFREE(char *) xmlStr = NULL;
+ g_autofree char *xmlStr = NULL;
switch ((virDomainDeviceType) src->type) {
case VIR_DOMAIN_DEVICE_DISK:
wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] = {0};
size_t len = 0;
char *ret = NULL;
- VIR_AUTOFREE(char *) shortname = NULL;
+ g_autofree char *shortname = NULL;
/* No need to do the whole conversion thing when there are no multibyte
* characters. The same applies for illegal sequences as they can occur
VIR_AUTOUNREF(virNetworkPtr) net = NULL;
VIR_AUTOPTR(virNetworkPortDef) portdef = NULL;
VIR_AUTOUNREF(virNetworkPortPtr) port = NULL;
- VIR_AUTOFREE(char *) portxml = NULL;
+ g_autofree char *portxml = NULL;
if (!(net = virNetworkLookupByName(conn, iface->data.network.name)))
return -1;
{
virNetworkDefPtr def = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
VIR_AUTOUNREF(virConnectPtr) conn = NULL;
VIR_AUTOUNREF(virNetworkPtr) net = NULL;
{
virStorageVolInfo info;
VIR_AUTOPTR(virStoragePoolDef) pooldef = NULL;
- VIR_AUTOFREE(char *) poolxml = NULL;
+ g_autofree char *poolxml = NULL;
VIR_AUTOUNREF(virConnectPtr) conn = NULL;
VIR_AUTOUNREF(virStoragePoolPtr) pool = NULL;
VIR_AUTOUNREF(virStorageVolPtr) vol = NULL;
{
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
VIR_AUTOPTR(virSecretDef) def = NULL;
- VIR_AUTOFREE(char *) prop = NULL;
- VIR_AUTOFREE(char *) uuidstr = NULL;
+ g_autofree char *prop = NULL;
+ g_autofree char *uuidstr = NULL;
if (!virXMLNodeNameEqual(root, "secret")) {
virReportError(VIR_ERR_XML_ERROR,
}
if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE) {
- VIR_AUTOFREE(char *) schema = NULL;
+ g_autofree char *schema = NULL;
schema = virFileFindResource("domainsnapshot.rng",
abs_top_srcdir "/docs/schemas",
virStoragePoolOptionsPtr options;
int n;
VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
- VIR_AUTOFREE(char *) port = NULL;
- VIR_AUTOFREE(char *) ver = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodeset = NULL;
- VIR_AUTOFREE(char *) sourcedir = NULL;
+ g_autofree char *port = NULL;
+ g_autofree char *ver = NULL;
+ g_autofree xmlNodePtr *nodeset = NULL;
+ g_autofree char *sourcedir = NULL;
relnode = ctxt->node;
ctxt->node = node;
}
if (options->formatFromString) {
- VIR_AUTOFREE(char *) format = NULL;
+ g_autofree char *format = NULL;
format = virXPathString("string(./format/@type)", ctxt);
if (format == NULL)
goto cleanup;
for (i = 0; i < nsource; i++) {
- VIR_AUTOFREE(char *) partsep = NULL;
+ g_autofree char *partsep = NULL;
virStoragePoolSourceDevice dev = { .path = NULL };
dev.path = virXMLPropString(nodeset[i], "path");
int ret = -1;
xmlNodePtr relnode;
xmlNodePtr node;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *mode = NULL;
node = virXPathNode(permxpath, ctxt);
if (node == NULL) {
virStoragePoolDefRefreshParse(xmlXPathContextPtr ctxt,
virStoragePoolDefPtr def)
{
- VIR_AUTOFREE(virStoragePoolDefRefreshPtr) refresh = NULL;
- VIR_AUTOFREE(char *) allocation = NULL;
+ g_autofree virStoragePoolDefRefreshPtr refresh = NULL;
+ g_autofree char *allocation = NULL;
int tmp;
allocation = virXPathString("string(./refresh/volume/@allocation)", ctxt);
virStoragePoolDefPtr ret = NULL;
xmlNodePtr source_node;
VIR_AUTOPTR(virStoragePoolDef) def = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) uuid = NULL;
- VIR_AUTOFREE(char *) target_path = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *uuid = NULL;
+ g_autofree char *target_path = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
size_t i;
int n;
VIR_AUTOPTR(virStorageVolDef) def = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) allocation = NULL;
- VIR_AUTOFREE(char *) capacity = NULL;
- VIR_AUTOFREE(char *) unit = NULL;
- VIR_AUTOFREE(char *) backingStore = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *allocation = NULL;
+ g_autofree char *capacity = NULL;
+ g_autofree char *unit = NULL;
+ g_autofree char *backingStore = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY |
VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL);
backingStore = NULL;
if (options->formatFromString) {
- VIR_AUTOFREE(char *) format = NULL;
+ g_autofree char *format = NULL;
format = virXPathString("string(./backingStore/format/@type)", ctxt);
if (format == NULL)
def->target.path = virXPathString("string(./target/path)", ctxt);
if (options->formatFromString) {
- VIR_AUTOFREE(char *) format = NULL;
+ g_autofree char *format = NULL;
format = virXPathString("string(./target/format/@type)", ctxt);
if (format == NULL)
virStoragePoolDefPtr def)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
virBufferAddLit(&buf, "<poolstate>\n");
virBufferAdjustIndent(&buf, 2);
virStoragePoolSaveConfig(const char *configFile,
virStoragePoolDefPtr def)
{
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
if (!(xml = virStoragePoolDefFormat(def))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
const char *stateDir)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- VIR_AUTOFREE(char *) dir = NULL;
+ g_autofree char *dir = NULL;
virUUIDFormat(portdef->uuid, uuidstr);
const char *stateDir)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
- VIR_AUTOFREE(char *) dir = NULL;
+ g_autofree char *dir = NULL;
virNetworkPortDefPtr portdef;
virUUIDFormat(uuid, uuidstr);
virNetworkObjDeleteAllPorts(virNetworkObjPtr net,
const char *stateDir)
{
- VIR_AUTOFREE(char *) dir = NULL;
+ g_autofree char *dir = NULL;
DIR *dh = NULL;
struct dirent *de;
int rc;
virNetworkObjLoadAllPorts(virNetworkObjPtr net,
const char *stateDir)
{
- VIR_AUTOFREE(char *) dir = NULL;
+ g_autofree char *dir = NULL;
DIR *dh = NULL;
struct dirent *de;
int ret = -1;
virNetworkPortDefParseXML(xmlXPathContextPtr ctxt)
{
VIR_AUTOPTR(virNetworkPortDef) def = NULL;
- VIR_AUTOFREE(char *) uuid = NULL;
+ g_autofree char *uuid = NULL;
xmlNodePtr virtPortNode;
xmlNodePtr vlanNode;
xmlNodePtr bandwidthNode;
xmlNodePtr addressNode;
- VIR_AUTOFREE(char *) trustGuestRxFilters = NULL;
- VIR_AUTOFREE(char *) mac = NULL;
- VIR_AUTOFREE(char *) macmgr = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
- VIR_AUTOFREE(char *) plugtype = NULL;
- VIR_AUTOFREE(char *) managed = NULL;
- VIR_AUTOFREE(char *) driver = NULL;
+ g_autofree char *trustGuestRxFilters = NULL;
+ g_autofree char *mac = NULL;
+ g_autofree char *macmgr = NULL;
+ g_autofree char *mode = NULL;
+ g_autofree char *plugtype = NULL;
+ g_autofree char *managed = NULL;
+ g_autofree char *driver = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
xmlXPathContextPtr ctxt,
virCPUx86MapPtr map)
{
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
virCPUx86ModelPtr ancestor;
int rc;
x86ModelParseSignatures(virCPUx86ModelPtr model,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
xmlNodePtr root = ctxt->node;
size_t i;
int n;
xmlXPathContextPtr ctxt,
virCPUx86MapPtr map)
{
- VIR_AUTOFREE(char *) vendor = NULL;
+ g_autofree char *vendor = NULL;
int rc;
if ((rc = virXPathBoolean("boolean(./vendor)", ctxt)) <= 0)
xmlXPathContextPtr ctxt,
virCPUx86MapPtr map)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
size_t i;
int n;
return n;
for (i = 0; i < n; i++) {
- VIR_AUTOFREE(char *) ftname = NULL;
+ g_autofree char *ftname = NULL;
virCPUx86FeaturePtr feature;
if (!(ftname = virXMLPropString(nodes[i], "name"))) {
virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
virCPUx86VendorPtr vendor;
virDomainCapsCPUModelPtr hvModel = NULL;
- VIR_AUTOFREE(char *) sigs = NULL;
+ g_autofree char *sigs = NULL;
uint32_t signature;
ssize_t i;
int rc;
virDriverShouldAutostart(const char *dir,
bool *autostart)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
*autostart = false;
VIR_DEBUG("Return cached %s connection %p", name, conn);
virObjectRef(conn);
} else {
- VIR_AUTOFREE(char *) uri = NULL;
+ g_autofree char *uri = NULL;
const char *uriPath = geteuid() == 0 ? "/system" : "/session";
if (virAsprintf(&uri, "%s://%s", name, uriPath) < 0)
"%s/libvirt/interface", RUNSTATEDIR) < 0)
goto error;
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto error;
"%s/libvirt/interface", RUNSTATEDIR) < 0)
goto cleanup;
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto cleanup;
}
if (!sock_path) {
- VIR_AUTOFREE(char *) sockbase = NULL;
+ g_autofree char *sockbase = NULL;
bool legacy = false;
if (!uri->scheme) {
static int
xenConfigGetUUID(virConfPtr conf, const char *name, unsigned char *uuid)
{
- VIR_AUTOFREE(char *) string = NULL;
+ g_autofree char *string = NULL;
int rc;
if (!uuid || !name || !conf) {
static int
xenParseEventsActions(virConfPtr conf, virDomainDefPtr def)
{
- VIR_AUTOFREE(char *) on_poweroff = NULL;
- VIR_AUTOFREE(char *) on_reboot = NULL;
- VIR_AUTOFREE(char *) on_crash = NULL;
+ g_autofree char *on_poweroff = NULL;
+ g_autofree char *on_reboot = NULL;
+ g_autofree char *on_crash = NULL;
if (xenConfigGetString(conf, "on_poweroff", &on_poweroff, "destroy") < 0)
return -1;
virDomainXMLOptionPtr xmlopt)
{
unsigned long count = 0;
- VIR_AUTOFREE(char *) cpus = NULL;
- VIR_AUTOFREE(char *) tsc_mode = NULL;
+ g_autofree char *cpus = NULL;
+ g_autofree char *tsc_mode = NULL;
int val = 0;
virDomainTimerDefPtr timer;
virDomainChrDefPtr chr = NULL;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- VIR_AUTOFREE(char *) parallel = NULL;
+ g_autofree char *parallel = NULL;
int rc;
if (xenConfigGetString(conf, "parallel", ¶llel, NULL) < 0)
goto cleanup;
}
} else {
- VIR_AUTOFREE(char *) serial = NULL;
+ g_autofree char *serial = NULL;
if (xenHandleConfGetValueStringListErrors(rc) < 0)
goto cleanup;
static int
xenParseEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetString(conf, "soundhw", &str, NULL) < 0)
xenParseGeneralMeta(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
{
virCapsDomainDataPtr capsdata = NULL;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
int ret = -1;
if (xenConfigCopyString(conf, "name", &def->name) < 0)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
const char * model;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
size_t i;
if (def->os.type != VIR_DOMAIN_OSTYPE_HVM ||
static int xenParseCmdline(virConfPtr conf, char **r_cmdline)
{
char *cmdline = NULL;
- VIR_AUTOFREE(char *) root = NULL;
- VIR_AUTOFREE(char *) extra = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *root = NULL;
+ g_autofree char *extra = NULL;
+ g_autofree char *buf = NULL;
if (xenConfigGetString(conf, "cmdline", &buf, NULL) < 0)
return -1;
size_t i;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- VIR_AUTOFREE(char *) bios = NULL;
- VIR_AUTOFREE(char *) boot = NULL;
+ g_autofree char *bios = NULL;
+ g_autofree char *boot = NULL;
int val = 0;
if (xenConfigGetString(conf, "bios", &bios, NULL) < 0)
static int
xenParseXLCPUID(virConfPtr conf, virDomainDefPtr def)
{
- VIR_AUTOFREE(char *) cpuid_str = NULL;
+ g_autofree char *cpuid_str = NULL;
char **cpuid_pairs = NULL;
char **name_and_value = NULL;
size_t i;
size_t i;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
- VIR_AUTOFREE(char *) boot = NULL;
+ g_autofree char *boot = NULL;
if (VIR_ALLOC(def->os.loader) < 0 ||
xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0)
def->os.nBootDevs++;
}
} else {
- VIR_AUTOFREE(char *) extra = NULL;
- VIR_AUTOFREE(char *) root = NULL;
+ g_autofree char *extra = NULL;
+ g_autofree char *root = NULL;
if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0)
return -1;
static int
xenParseXMInputDevs(virConfPtr conf, virDomainDefPtr def)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xenConfigGetString(conf, "usbdevice", &str, NULL) < 0)
virConfPtr properties)
{
int type = VIR_DOMAIN_FS_TYPE_MOUNT;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
if (virConfGetValueString(properties, "lxc.rootfs.path", &value) <= 0) {
virResetLastError();
static int
lxcCreateConsoles(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
int nbttys = 0;
virDomainChrDefPtr console;
size_t i;
static int
lxcSetMemTune(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
unsigned long long size = 0;
if (virConfGetValueString(properties,
static int
lxcSetCpuTune(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
if (virConfGetValueString(properties, "lxc.cgroup.cpu.shares",
&value) > 0) {
static int
lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
virBitmapPtr nodeset = NULL;
if (virConfGetValueString(properties, "lxc.cgroup.cpuset.cpus",
static int
lxcSetBlkioTune(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
if (virConfGetValueString(properties, "lxc.cgroup.blkio.weight",
&value) > 0) {
static void
lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
char **toDrop = NULL;
const char *capString;
size_t i;
{
virDomainDefPtr vmdef = NULL;
VIR_AUTOPTR(virConf) properties = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT)))
return NULL;
networkDnsmasqDefNamespaceParseOptions(networkDnsmasqXmlNsDefPtr nsdef,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes;
size_t i;
} else if (dbus_message_is_signal(message,
DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) old_owner = NULL;
- VIR_AUTOFREE(char *) new_owner = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *old_owner = NULL;
+ g_autofree char *new_owner = NULL;
if (virDBusMessageDecode(message, "sss", &name, &old_owner, &new_owner) < 0) {
VIR_WARN("Failed to decode DBus NameOwnerChanged message");
} else {
/* IPv4 - dnsmasq requires a netmask rather than prefix */
virSocketAddr netmask;
- VIR_AUTOFREE(char *) netmaskStr = NULL;
+ g_autofree char *netmaskStr = NULL;
if (virSocketAddrPrefixToNetmask(prefix, &netmask, AF_INET) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s/libvirt/nodedev", RUNSTATEDIR) < 0)
goto failure;
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto failure;
"%s/libvirt/nodedev", RUNSTATEDIR) < 0)
goto cleanup;
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
if (!(rundir = virGetUserRuntimeDirectory()))
goto cleanup;
{
qemuBlockNodeNameBackingChainDataPtr entry = NULL;
virStorageSourcePtr src = disk->src;
- VIR_AUTOFREE(char *) alias = NULL;
+ g_autofree char *alias = NULL;
int ret = -1;
/* don't attempt the detection if the top level already has node names */
VIR_AUTOPTR(virJSONValue) server = NULL;
const char *transport;
const char *field;
- VIR_AUTOFREE(char *) port = NULL;
+ g_autofree char *port = NULL;
switch ((virStorageNetHostTransport) host->transport) {
case VIR_STORAGE_NET_HOST_TRANS_TCP:
qemuBlockStorageSourceBuildJSONInetSocketAddress(virStorageNetHostDefPtr host)
{
virJSONValuePtr ret = NULL;
- VIR_AUTOFREE(char *) port = NULL;
+ g_autofree char *port = NULL;
if (host->transport != VIR_STORAGE_NET_HOST_TRANS_TCP) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
const char *username = NULL;
virJSONValuePtr ret = NULL;
VIR_AUTOPTR(virURI) uri = NULL;
- VIR_AUTOFREE(char *) uristr = NULL;
+ g_autofree char *uristr = NULL;
/**
* Common options:
bool onlytarget)
{
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
- VIR_AUTOFREE(char *) target = NULL;
+ g_autofree char *target = NULL;
char *lunStr = NULL;
char *username = NULL;
char *objalias = NULL;
- VIR_AUTOFREE(char *) portal = NULL;
+ g_autofree char *portal = NULL;
unsigned int lun = 0;
virJSONValuePtr ret = NULL;
bool reuse)
{
const char *format = virStorageFileFormatTypeToString(newsrc->format);
- VIR_AUTOFREE(char *) device = NULL;
- VIR_AUTOFREE(char *) source = NULL;
+ g_autofree char *device = NULL;
+ g_autofree char *source = NULL;
if (!(device = qemuAliasDiskDriveFromDisk(disk)))
return -1;
int actualType = virStorageSourceGetActualType(src);
VIR_AUTOPTR(virJSONValue) backingProps = NULL;
VIR_AUTOPTR(virURI) uri = NULL;
- VIR_AUTOFREE(char *) backingJSON = NULL;
+ g_autofree char *backingJSON = NULL;
char *ret = NULL;
if (virStorageSourceIsLocalStorage(src)) {
virJSONValuePtr props,
bool format)
{
- VIR_AUTOFREE(char *) backingFileStr = NULL;
+ g_autofree char *backingFileStr = NULL;
const char *backingFormatStr = NULL;
if (!virStorageSourceIsBacking(backing))
{
qemuDomainStorageSourcePrivatePtr srcpriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
VIR_AUTOPTR(virJSONValue) props = NULL;
- VIR_AUTOFREE(char *) cipheralg = NULL;
+ g_autofree char *cipheralg = NULL;
const char *keysecret = NULL;
if (srcpriv &&
{
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
- VIR_AUTOFREE(char *) jobname = NULL;
+ g_autofree char *jobname = NULL;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
if (virAsprintf(&jobname, "pull-%s-%s", disk->dst, disk->src->nodeformat) < 0)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
- VIR_AUTOFREE(char *) jobname = NULL;
+ g_autofree char *jobname = NULL;
qemuBlockJobType jobtype = QEMU_BLOCKJOB_TYPE_COMMIT;
if (topparent == NULL)
bool storage)
{
VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
- VIR_AUTOFREE(char *) jobname = NULL;
+ g_autofree char *jobname = NULL;
const char *nodename = src->nodeformat;
if (storage)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
- VIR_AUTOFREE(char *) jobname = NULL;
+ g_autofree char *jobname = NULL;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) {
if (virAsprintf(&jobname, "copy-%s-%s", disk->dst, disk->src->nodeformat) < 0)
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) {
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, props.type);
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *type = NULL;
if (!virQEMUCapsIsMachineSupported(qemuCaps, canon))
continue;
{
static char const * const kmod[] = {"kvm_intel", "kvm_amd",
"kvm_hv", "kvm"};
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
int rc;
size_t i;
qemuMonitorPtr mon)
{
int major, minor, micro;
- VIR_AUTOFREE(char *) package = NULL;
+ g_autofree char *package = NULL;
/* @mon is supposed to be locked by callee */
{
unsigned int flags = VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE;
virDomainCheckpointDefPtr def = virDomainCheckpointObjGetDef(checkpoint);
- VIR_AUTOFREE(char *) newxml = NULL;
- VIR_AUTOFREE(char *) chkDir = NULL;
- VIR_AUTOFREE(char *) chkFile = NULL;
+ g_autofree char *newxml = NULL;
+ g_autofree char *chkDir = NULL;
+ g_autofree char *chkFile = NULL;
newxml = virDomainCheckpointDefFormat(def, caps, xmlopt, flags);
if (newxml == NULL)
virDomainCheckpointDefPtr parentdef = NULL;
size_t i, j;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- VIR_AUTOFREE(char *) chkFile = NULL;
+ g_autofree char *chkFile = NULL;
if (!metadata_only && !virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
qemuDomainObjPrivatePtr priv)
{
- VIR_AUTOFREE(char *) alias = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *alias = NULL;
+ g_autofree char *path = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
/* If the -object secret does not exist, then just return. This just
virDomainDeviceInfoPtr info,
virQEMUCapsPtr qemuCaps)
{
- VIR_AUTOFREE(char *) devStr = NULL;
+ g_autofree char *devStr = NULL;
const char *contAlias = NULL;
bool contIsPHB = false;
int contTargetIndex = 0;
virJSONValuePtr *propsret)
{
int ret = -1;
- VIR_AUTOFREE(char *) keyid = NULL;
+ g_autofree char *keyid = NULL;
if (!(keyid = qemuDomainGetMasterKeyAlias()))
return -1;
qemuCheckFips(void)
{
if (virFileExists("/proc/sys/crypto/fips_enabled")) {
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
if (virFileReadAll("/proc/sys/crypto/fips_enabled", 10, &buf) < 0)
return false;
qemuBuildDriveSourcePR(virBufferPtr buf,
virDomainDiskDefPtr disk)
{
- VIR_AUTOFREE(char *) alias = NULL;
+ g_autofree char *alias = NULL;
const char *defaultAlias = NULL;
if (!disk->src->pr)
qemuDomainSecretInfoPtr secinfo = NULL;
qemuDomainSecretInfoPtr encinfo = NULL;
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
- VIR_AUTOFREE(char *) source = NULL;
+ g_autofree char *source = NULL;
bool rawluks = false;
if (srcpriv) {
goto error;
if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
- VIR_AUTOFREE(char *) drivealias = qemuAliasDiskDriveFromDisk(disk);
+ g_autofree char *drivealias = qemuAliasDiskDriveFromDisk(disk);
if (!drivealias)
goto error;
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
const char *contAlias;
- VIR_AUTOFREE(char *) backendAlias = NULL;
- VIR_AUTOFREE(char *) scsiVPDDeviceId = NULL;
+ g_autofree char *backendAlias = NULL;
+ g_autofree char *scsiVPDDeviceId = NULL;
int controllerModel;
if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
qemuCommandAddZPCIDevice(virCommandPtr cmd,
virDomainDeviceInfoPtr dev)
{
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
virCommandAddArg(cmd, "-device");
virBufferAddLit(&fdc_opts, "isa-fdc,");
for (i = 0; i < def->ndisks; i++) {
- VIR_AUTOFREE(char *) backendAlias = NULL;
- VIR_AUTOFREE(char *) backendStr = NULL;
- VIR_AUTOFREE(char *) bootindexStr = NULL;
+ g_autofree char *backendAlias = NULL;
+ g_autofree char *backendStr = NULL;
+ g_autofree char *bootindexStr = NULL;
virDomainDiskDefPtr disk = def->disks[i];
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
{
VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
VIR_AUTOPTR(virJSONValue) copyOnReadProps = NULL;
- VIR_AUTOFREE(char *) copyOnReadPropsStr = NULL;
+ g_autofree char *copyOnReadPropsStr = NULL;
size_t i;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
virQEMUCapsPtr qemuCaps,
unsigned int bootindex)
{
- VIR_AUTOFREE(char *) optstr = NULL;
+ g_autofree char *optstr = NULL;
if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0)
return -1;
const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
- VIR_AUTOFREE(char *) fsdevstr = NULL;
- VIR_AUTOFREE(char *) devicestr = NULL;
+ g_autofree char *fsdevstr = NULL;
+ g_autofree char *devicestr = NULL;
virCommandAddArg(cmd, "-fsdev");
if (!(fsdevstr = qemuBuildFSStr(fs)))
for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i];
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (cont->type != type)
continue;
const long system_page_size = virGetSystemPageSizeKB();
virDomainMemoryAccess memAccess = mem->access;
size_t i;
- VIR_AUTOFREE(char *) memPath = NULL;
+ g_autofree char *memPath = NULL;
bool prealloc = false;
virBitmapPtr nodemask = NULL;
int rc;
virBufferPtr buf)
{
VIR_AUTOPTR(virJSONValue) props = NULL;
- VIR_AUTOFREE(char *) alias = NULL;
+ g_autofree char *alias = NULL;
int rc;
virDomainMemoryDef mem = { 0 };
unsigned long long memsize = virDomainNumaGetNodeMemorySize(def->numa,
qemuDomainObjPrivatePtr priv)
{
VIR_AUTOPTR(virJSONValue) props = NULL;
- VIR_AUTOFREE(char *) alias = NULL;
+ g_autofree char *alias = NULL;
if (!mem->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virBufferAddLit(&buf, "user,");
for (i = 0; i < net->guestIP.nips; i++) {
const virNetDevIPAddr *ip = net->guestIP.ips[i];
- VIR_AUTOFREE(char *) addr = NULL;
+ g_autofree char *addr = NULL;
const char *prefix = "";
if (!(addr = virSocketAddrFormat(&ip->address)))
virQEMUCapsPtr qemuCaps)
{
virDomainWatchdogDefPtr watchdog = def->watchdog;
- VIR_AUTOFREE(char *) optstr = NULL;
+ g_autofree char *optstr = NULL;
const char *action;
int actualAction;
return -1;
}
- VIR_AUTOFREE(char *) optstr = NULL;
+ g_autofree char *optstr = NULL;
virCommandAddArg(cmd, "-global");
optstr = qemuBuildNVRAMDevStr(def->nvram);
if (!optstr)
for (i = 0; i < def->ninputs; i++) {
virDomainInputDefPtr input = def->inputs[i];
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (qemuCommandAddExtDevice(cmd, &input->info) < 0)
return -1;
for (i = 0; i < def->nsounds; i++) {
virDomainSoundDefPtr sound = def->sounds[i];
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
/* Sadly pcspk device doesn't use -device syntax. Fortunately
* we don't need to set any PCI address on it, so we don't
sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
for (j = 0; j < sound->ncodecs; j++) {
- VIR_AUTOFREE(char *) codecstr = NULL;
+ g_autofree char *codecstr = NULL;
virCommandAddArg(cmd, "-device");
if (!(codecstr =
qemuBuildSoundCodecStr(sound, sound->codecs[j],
virCommandAddArg(cmd, codecstr);
}
if (j == 0) {
- VIR_AUTOFREE(char *) codecstr = NULL;
+ g_autofree char *codecstr = NULL;
virDomainSoundCodecDef codec = {
VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
0
size_t i;
for (i = 0; i < def->nvideos; i++) {
- VIR_AUTOFREE(char *) chardev = NULL;
+ g_autofree char *chardev = NULL;
virDomainVideoDefPtr video = def->videos[i];
if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
}
for (i = 0; i < def->nvideos; i++) {
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
virDomainVideoDefPtr video = def->videos[i];
if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
for (i = 0; i < def->nhubs; i++) {
virDomainHubDefPtr hub = def->hubs[i];
- VIR_AUTOFREE(char *) optstr = NULL;
+ g_autofree char *optstr = NULL;
virCommandAddArg(cmd, "-device");
if (!(optstr = qemuBuildHubDevStr(def, hub, qemuCaps)))
virQEMUCapsPtr qemuCaps)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) netsource = NULL;
+ g_autofree char *netsource = NULL;
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
virQEMUCapsPtr qemuCaps)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) source = NULL;
- VIR_AUTOFREE(char *) drivealias = NULL;
+ g_autofree char *source = NULL;
+ g_autofree char *drivealias = NULL;
virDomainHostdevSubsysSCSIPtr scsisrc = &dev->source.subsys.u.scsi;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
int model = -1;
- VIR_AUTOFREE(char *) driveAlias = NULL;
+ g_autofree char *driveAlias = NULL;
const char *contAlias;
model = qemuDomainFindSCSIControllerModel(def, dev->info);
const char *appendarg, int appendval)
{
if (logManager) {
- VIR_AUTOFREE(char *) fdset = NULL;
- VIR_AUTOFREE(char *) fdpath = NULL;
+ g_autofree char *fdset = NULL;
+ g_autofree char *fdpath = NULL;
int flags = 0;
int logfd;
qemuDomainChrSourcePrivatePtr chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev);
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
bool telnet;
- VIR_AUTOFREE(char *) charAlias = NULL;
+ g_autofree char *charAlias = NULL;
if (!(charAlias = qemuAliasChardevFromDevAlias(alias)))
return NULL;
qemuBuildChrChardevReconnectStr(&buf, &dev->data.tcp.reconnect);
if (dev->data.tcp.haveTLS == VIR_TRISTATE_BOOL_YES) {
- VIR_AUTOFREE(char *) objalias = NULL;
+ g_autofree char *objalias = NULL;
const char *tlsCertEncSecAlias = NULL;
/* Add the secret object first if necessary. The
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
- VIR_AUTOFREE(char *) mdevPath = NULL;
+ g_autofree char *mdevPath = NULL;
const char *dev_str = NULL;
if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
for (i = 0; i < def->nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
/* USB */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
if (virHostdevIsSCSIDevice(hostdev)) {
virDomainHostdevSubsysSCSIPtr scsisrc =
&hostdev->source.subsys.u.scsi;
- VIR_AUTOFREE(char *) drvstr = NULL;
+ g_autofree char *drvstr = NULL;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST) {
if (hostdev->source.subsys.u.scsi_host.protocol ==
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST) {
- VIR_AUTOFREE(char *) vhostfdName = NULL;
+ g_autofree char *vhostfdName = NULL;
int vhostfd = -1;
if (virSCSIVHostOpenVhostSCSI(&vhostfd) < 0)
virDomainDefPtr def,
qemuDomainObjPrivatePtr priv)
{
- VIR_AUTOFREE(char *) chrdev = NULL;
+ g_autofree char *chrdev = NULL;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
if (priv->chardevStdioLogd)
virQEMUCapsPtr qemuCaps,
virJSONValuePtr *props)
{
- VIR_AUTOFREE(char *) objAlias = NULL;
- VIR_AUTOFREE(char *) charBackendAlias = NULL;
+ g_autofree char *objAlias = NULL;
+ g_autofree char *charBackendAlias = NULL;
if (virAsprintf(&objAlias, "obj%s", rng->info.alias) < 0)
return -1;
VIR_AUTOPTR(virJSONValue) props = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainRNGDefPtr rng = def->rngs[i];
- VIR_AUTOFREE(char *) chardev = NULL;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *chardev = NULL;
+ g_autofree char *devstr = NULL;
int rc;
if (!rng->info.alias) {
virQEMUCapsPtr qemuCaps)
{
size_t i;
- VIR_AUTOFREE(char *) rtcopt = NULL;
+ g_autofree char *rtcopt = NULL;
virCommandAddArg(cmd, "-rtc");
if (!(rtcopt = qemuBuildClockArgStr(&def->clock)))
virQEMUCapsPtr qemuCaps)
{
g_auto(virBuffer) boot_buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) boot_opts_str = NULL;
+ g_autofree char *boot_opts_str = NULL;
if (def->os.bootmenu) {
if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES)
virQEMUCapsPtr qemuCaps)
{
virArch hostarch = virArchFromHost();
- VIR_AUTOFREE(char *) cpu = NULL;
- VIR_AUTOFREE(char *) cpu_flags = NULL;
+ g_autofree char *cpu = NULL;
+ g_autofree char *cpu_flags = NULL;
g_auto(virBuffer) cpu_buf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
qemuDomainObjPrivatePtr priv)
{
const long system_page_size = virGetSystemPageSizeKB();
- VIR_AUTOFREE(char *) mem_path = NULL;
+ g_autofree char *mem_path = NULL;
/* There are two cases where we want to put -mem-path onto
* the command line: First one is when there are no guest
{
virDomainDefPtr def = vm->def;
int ret = -1;
- VIR_AUTOFREE(char *) nic = NULL;
- VIR_AUTOFREE(char *) host = NULL;
- VIR_AUTOFREE(char *) chardev = NULL;
+ g_autofree char *nic = NULL;
+ g_autofree char *host = NULL;
+ g_autofree char *chardev = NULL;
int *tapfd = NULL;
size_t tapfdSize = 0;
int *vhostfd = NULL;
size_t vhostfdSize = 0;
char **tapfdName = NULL;
char **vhostfdName = NULL;
- VIR_AUTOFREE(char *) slirpfdName = NULL;
+ g_autofree char *slirpfdName = NULL;
virDomainNetType actualType = virDomainNetGetActualType(net);
virNetDevBandwidthPtr actualBandwidth;
bool requireNicdev = false;
{
size_t i;
virDomainSmartcardDefPtr smartcard;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
const char *database;
const char *contAlias = NULL;
virJSONValuePtr
qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
{
- VIR_AUTOFREE(char *) mem_alias = NULL;
- VIR_AUTOFREE(char *) mem_path = NULL;
+ g_autofree char *mem_alias = NULL;
+ g_autofree char *mem_path = NULL;
virJSONValuePtr ret = NULL;
if (virAsprintf(&mem_path, "/dev/shm/%s", shmem->name) < 0)
{
VIR_AUTOPTR(virJSONValue) memProps = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) chardev = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *chardev = NULL;
int rc;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
virDomainChrDefPtr chr,
virQEMUCapsPtr qemuCaps)
{
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (qemuBuildChrDeviceStr(&devstr, def, chr, qemuCaps) < 0)
return -1;
for (i = 0; i < def->nserials; i++) {
virDomainChrDefPtr serial = def->serials[i];
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (serial->source->type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice)
continue;
for (i = 0; i < def->nparallels; i++) {
virDomainChrDefPtr parallel = def->parallels[i];
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (!(devstr = qemuBuildChrChardevStr(logManager, secManager,
cmd, cfg, def,
{
const virDomainTPMDef *tpm = def->tpm;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) cancel_path = NULL;
- VIR_AUTOFREE(char *) devset = NULL;
- VIR_AUTOFREE(char *) cancelset = NULL;
+ g_autofree char *cancel_path = NULL;
+ g_autofree char *devset = NULL;
+ g_autofree char *cancelset = NULL;
const char *tpmdev;
*tpmfd = -1;
virQEMUCapsPtr qemuCaps)
{
char *optstr;
- VIR_AUTOFREE(char *) chardev = NULL;
+ g_autofree char *chardev = NULL;
int tpmfd = -1;
int cancelfd = -1;
char *fdset;
virJSONValuePtr
qemuBuildPRManagedManagerInfoProps(qemuDomainObjPrivatePtr priv)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (!(path = qemuDomainGetManagedPRSocketPath(priv)))
return NULL;
qemuBuildDBusVMStateInfoProps(const char *id,
const char *addr)
{
- VIR_AUTOFREE(char *) alias = qemuAliasDBusVMStateFromId(id);
+ g_autofree char *alias = qemuAliasDBusVMStateFromId(id);
if (!alias)
return NULL;
virQEMUCapsPtr qemuCaps)
{
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, "")))
return -1;
virDomainChrDefPtr chr)
{
int ret = -1;
- VIR_AUTOFREE(char *) addr = NULL;
+ g_autofree char *addr = NULL;
int port;
switch ((virDomainChrChannelTargetType)chr->targetType) {
virGetGroupID("tss", &cfg->swtpm_group) < 0)
cfg->swtpm_group = 0; /* fall back to root */
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
- VIR_AUTOFREE(char *) cachedir = NULL;
+ g_autofree char *rundir = NULL;
+ g_autofree char *cachedir = NULL;
cachedir = virGetUserCacheDirectory();
if (!cachedir)
virConfPtr conf)
{
VIR_AUTOSTRINGLIST hugetlbfs = NULL;
- VIR_AUTOFREE(char *) stdioHandler = NULL;
- VIR_AUTOFREE(char *) corestr = NULL;
+ g_autofree char *stdioHandler = NULL;
+ g_autofree char *corestr = NULL;
size_t i;
if (virConfGetValueStringList(conf, "hugetlbfs_mount", true,
{
VIR_AUTOSTRINGLIST controllers = NULL;
VIR_AUTOSTRINGLIST namespaces = NULL;
- VIR_AUTOFREE(char *) user = NULL;
- VIR_AUTOFREE(char *) group = NULL;
+ g_autofree char *user = NULL;
+ g_autofree char *group = NULL;
size_t i, j;
if (virConfGetValueStringList(conf, "security_driver", true, &cfg->securityDriverNames) < 0)
virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg,
virConfPtr conf)
{
- VIR_AUTOFREE(char *) swtpm_user = NULL;
- VIR_AUTOFREE(char *) swtpm_group = NULL;
+ g_autofree char *swtpm_user = NULL;
+ g_autofree char *swtpm_group = NULL;
if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0)
return -1;
{
size_t i, j;
VIR_AUTOUNREF(virCapsPtr) caps = NULL;
- VIR_AUTOFREE(virSecurityManagerPtr) *sec_managers = NULL;
+ g_autofree virSecurityManagerPtr *sec_managers = NULL;
/* Security driver data */
const char *doi, *model, *lbl, *type;
const int virtTypes[] = {VIR_DOMAIN_VIRT_KVM,
const char *device_path,
int sgio)
{
- VIR_AUTOFREE(char *) sysfs_path = NULL;
- VIR_AUTOFREE(char *) key = NULL;
+ g_autofree char *sysfs_path = NULL;
+ g_autofree char *key = NULL;
int val;
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(device_path, NULL)))
const char *name,
bool addDisk)
{
- VIR_AUTOFREE(char *) key = NULL;
+ g_autofree char *key = NULL;
int ret = -1;
if (virStorageSourceIsEmpty(disk->src) ||
{
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
- VIR_AUTOFREE(char *) dev_name = NULL;
+ g_autofree char *dev_name = NULL;
char *dev_path = NULL;
if (!(dev_name = virSCSIDeviceGetDevName(NULL,
const char *name,
bool addDevice)
{
- VIR_AUTOFREE(char *) dev_path = NULL;
- VIR_AUTOFREE(char *) key = NULL;
+ g_autofree char *dev_path = NULL;
+ g_autofree char *key = NULL;
int ret = -1;
if (!qemuIsSharedHostdev(hostdev))
{
virDomainDiskDefPtr disk = NULL;
virDomainHostdevDefPtr hostdev = NULL;
- VIR_AUTOFREE(char *) sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
const char *path = NULL;
int val = -1;
qemuGetDomainHugepagePath(const virDomainDef *def,
virHugeTLBFSPtr hugepage)
{
- VIR_AUTOFREE(char *) base = qemuGetBaseHugepagePath(hugepage);
- VIR_AUTOFREE(char *) domPath = virDomainDefGetShortName(def);
+ g_autofree char *base = qemuGetBaseHugepagePath(hugepage);
+ g_autofree char *domPath = virDomainDefGetShortName(def);
char *ret = NULL;
if (base && domPath)
virQEMUDriverConfigPtr cfg,
char **path)
{
- VIR_AUTOFREE(char *) shortName = NULL;
- VIR_AUTOFREE(char *) base = NULL;
+ g_autofree char *shortName = NULL;
+ g_autofree char *base = NULL;
if (!(shortName = virDomainDefGetShortName(def)) ||
qemuGetMemoryBackingBasePath(cfg, &base) < 0 ||
const char *alias,
char **memPath)
{
- VIR_AUTOFREE(char *) domainPath = NULL;
+ g_autofree char *domainPath = NULL;
if (!alias) {
/* This should never happen (TM) */
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(char *) format = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) index = NULL;
+ g_autofree char *format = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *index = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
xmlNodePtr sourceNode;
unsigned int xmlflags = VIR_DOMAIN_DEF_PARSE_STATUS;
virStorageSourcePtr *src,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(char *) nodename = NULL;
+ g_autofree char *nodename = NULL;
*src = NULL;
xmlXPathContextPtr ctxt,
virDomainXMLOptionPtr xmlopt)
{
- VIR_AUTOFREE(char *) createmode = NULL;
- VIR_AUTOFREE(char *) shallownew = NULL;
+ g_autofree char *createmode = NULL;
+ g_autofree char *shallownew = NULL;
xmlNodePtr tmp;
switch ((qemuBlockJobType) job->type) {
VIR_XPATH_NODE_AUTORESTORE(ctxt);
virDomainDiskDefPtr disk = NULL;
VIR_AUTOUNREF(qemuBlockJobDataPtr) job = NULL;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) typestr = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *typestr = NULL;
int type;
- VIR_AUTOFREE(char *) statestr = NULL;
+ g_autofree char *statestr = NULL;
int state = QEMU_BLOCKJOB_STATE_FAILED;
- VIR_AUTOFREE(char *) diskdst = NULL;
- VIR_AUTOFREE(char *) newstatestr = NULL;
- VIR_AUTOFREE(char *) mirror = NULL;
+ g_autofree char *diskdst = NULL;
+ g_autofree char *newstatestr = NULL;
+ g_autofree char *mirror = NULL;
int newstate = -1;
bool invalidData = false;
xmlNodePtr tmp;
qemuDomainObjPrivatePtr priv,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes = 0;
- VIR_AUTOFREE(char *) active = NULL;
+ g_autofree char *active = NULL;
int tmp;
size_t i;
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- VIR_AUTOFREE(char *) format = NULL;
- VIR_AUTOFREE(char *) type = NULL;
+ g_autofree char *format = NULL;
+ g_autofree char *type = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) migrSource = NULL;
xmlNodePtr sourceNode;
qemuSlirpPtr slirp)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
size_t i;
int n;
}
for (i = 0; i < n; i++) {
- VIR_AUTOFREE(char *) str = virXMLPropString(nodes[i], "name");
+ g_autofree char *str = virXMLPropString(nodes[i], "name");
int feature;
if (!str)
goto error;
}
for (i = 0; i < n; i++) {
- VIR_AUTOFREE(char *) alias = virXMLPropString(nodes[i], "alias");
- VIR_AUTOFREE(char *) pid = virXMLPropString(nodes[i], "pid");
+ g_autofree char *alias = virXMLPropString(nodes[i], "alias");
+ g_autofree char *pid = virXMLPropString(nodes[i], "pid");
VIR_AUTOPTR(qemuSlirp) slirp = qemuSlirpNew();
virDomainDeviceDef dev;
qemuDomainDefNamespaceParseCommandlineArgs(qemuDomainXmlNsDefPtr nsdef,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes;
size_t i;
qemuDomainDefNamespaceParseCommandlineEnv(qemuDomainXmlNsDefPtr nsdef,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes;
size_t i;
qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDefPtr nsdef,
xmlXPathContextPtr ctxt)
{
- VIR_AUTOFREE(xmlNodePtr *) nodesadd = NULL;
+ g_autofree xmlNodePtr *nodesadd = NULL;
ssize_t nnodesadd;
- VIR_AUTOFREE(xmlNodePtr *) nodesdel = NULL;
+ g_autofree xmlNodePtr *nodesdel = NULL;
ssize_t nnodesdel;
size_t i;
virDomainObjPtr vm)
{
virQEMUDriverConfigPtr cfg;
- VIR_AUTOFREE(char *) snapDir = NULL;
- VIR_AUTOFREE(char *) chkDir = NULL;
+ g_autofree char *snapDir = NULL;
+ g_autofree char *chkDir = NULL;
cfg = virQEMUDriverGetConfig(driver);
size_t i;
for (i = 0; i < G_N_ELEMENTS(nvlink2Files); i++) {
- VIR_AUTOFREE(char *) file = NULL;
+ g_autofree char *file = NULL;
if ((virAsprintf(&file, "/sys/bus/pci/devices/%s/of_node/%s",
device, nvlink2Files[i])) < 0)
pciAddr = &dev->source.subsys.u.pci.addr;
if (virPCIDeviceAddressIsValid(pciAddr, false)) {
- VIR_AUTOFREE(char *) pciAddrStr = NULL;
+ g_autofree char *pciAddrStr = NULL;
pciAddrStr = virPCIDeviceAddressAsString(pciAddr);
if (ppc64VFIODeviceIsNV2Bridge(pciAddrStr)) {
* inappropriate address types.
*/
if (!info->pciConnectFlags) {
- VIR_AUTOFREE(char *) addrStr = virPCIDeviceAddressAsString(&info->addr.pci);
+ g_autofree char *addrStr = virPCIDeviceAddressAsString(&info->addr.pci);
VIR_WARN("qemuDomainDeviceCalculatePCIConnectFlags() thinks that the "
"device with PCI address %s should not have a PCI address",
size_t i;
virPCIDeviceAddress tmp_addr;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
- VIR_AUTOFREE(char *) addrStr = NULL;
+ g_autofree char *addrStr = NULL;
virDomainPCIConnectFlags flags = (VIR_PCI_CONNECT_HOTPLUGGABLE
| VIR_PCI_CONNECT_TYPE_PCI_DEVICE);
size_t i;
virPCIDeviceAddress tmp_addr;
bool qemuDeviceVideoUsable = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
- VIR_AUTOFREE(char *) addrStr = NULL;
+ g_autofree char *addrStr = NULL;
virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
for (i = 0; i < def->ncontrollers; i++) {
{
unsigned int prefix_len;
virSocketAddr addr;
- VIR_AUTOFREE(char *) addrStr = NULL;
+ g_autofree char *addrStr = NULL;
int rc;
if (!virDomainObjIsActive(vm))
for (i = 0; i < vm->def->nnets; i++) {
virDomainNetDefPtr net = vm->def->nets[i];
unsigned int bootIndex = net->info.bootIndex;
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *model = NULL;
virMacAddr mac = net->mac;
char *script = net->script;
bool resume = false;
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap);
bool memory = snapdef->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
bool memory_unlink = false;
int thaw = 0; /* 1 if freeze succeeded, -1 if freeze failed */
bool pmsuspended = false;
int compressed;
- VIR_AUTOFREE(char *) compressedpath = NULL;
+ g_autofree char *compressedpath = NULL;
virQEMUSaveDataPtr data = NULL;
/* If quiesce was requested, then issue a freeze command, and a
virDomainDiskDefPtr disk;
virStorageSourcePtr baseSource = NULL;
unsigned int baseIndex = 0;
- VIR_AUTOFREE(char *) basePath = NULL;
- VIR_AUTOFREE(char *) backingPath = NULL;
+ g_autofree char *basePath = NULL;
+ g_autofree char *backingPath = NULL;
unsigned long long speed = bandwidth;
qemuBlockJobDataPtr job = NULL;
bool persistjob = false;
unsigned int baseIndex = 0;
virStorageSourcePtr top_parent = NULL;
bool clean_access = false;
- VIR_AUTOFREE(char *) topPath = NULL;
- VIR_AUTOFREE(char *) basePath = NULL;
- VIR_AUTOFREE(char *) backingPath = NULL;
+ g_autofree char *topPath = NULL;
+ g_autofree char *basePath = NULL;
+ g_autofree char *backingPath = NULL;
unsigned long long speed = bandwidth;
qemuBlockJobDataPtr job = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) mirror = NULL;
virDomainStatsRecordPtr *record,
unsigned int flags)
{
- VIR_AUTOFREE(virDomainStatsRecordPtr) tmp = NULL;
+ g_autofree virDomainStatsRecordPtr tmp = NULL;
VIR_AUTOPTR(virTypedParamList) params = NULL;
size_t i;
qemuAgentPtr agent;
int ret = -1;
int maxparams = 0;
- VIR_AUTOFREE(char *) hostname = NULL;
+ g_autofree char *hostname = NULL;
unsigned int supportedTypes = types;
int rc;
virCommandPtr cmd,
const char *info)
{
- VIR_AUTOFREE(char *) timestamp = virTimeStringNow();
- VIR_AUTOFREE(char *) cmds = virCommandToString(cmd, false);
+ g_autofree char *timestamp = virTimeStringNow();
+ g_autofree char *cmds = virCommandToString(cmd, false);
if (!timestamp || !cmds)
return -1;
for (j = 0; j < nmachines; j++) {
virJSONValuePtr machine = virJSONValueArrayGet(machines, j);
- VIR_AUTOFREE(char *) machineStr = NULL;
+ g_autofree char *machineStr = NULL;
if (VIR_STRDUP(machineStr, virJSONValueGetString(machine)) < 0)
goto cleanup;
qemuFirmwarePtr
qemuFirmwareParse(const char *path)
{
- VIR_AUTOFREE(char *) cont = NULL;
+ g_autofree char *cont = NULL;
VIR_AUTOPTR(virJSONValue) doc = NULL;
VIR_AUTOPTR(qemuFirmware) fw = NULL;
qemuFirmwarePtr ret = NULL;
qemuDomainAttachZPCIDevice(qemuMonitorPtr mon,
virDomainDeviceInfoPtr info)
{
- VIR_AUTOFREE(char *) devstr_zpci = NULL;
+ g_autofree char *devstr_zpci = NULL;
if (!(devstr_zpci = qemuBuildZPCIDevStr(info)))
return -1;
qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
virDomainDeviceInfoPtr info)
{
- VIR_AUTOFREE(char *) zpciAlias = NULL;
+ g_autofree char *zpciAlias = NULL;
if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid) < 0)
return -1;
bool force)
{
int rc;
- VIR_AUTOFREE(char *) driveAlias = NULL;
+ g_autofree char *driveAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
const char *format = NULL;
- VIR_AUTOFREE(char *) sourcestr = NULL;
+ g_autofree char *sourcestr = NULL;
if (!disk->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) alias = qemuAliasDBusVMStateFromId(id);
+ g_autofree char *alias = qemuAliasDBusVMStateFromId(id);
int ret;
if (!alias ||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend = NULL;
VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend = NULL;
- VIR_AUTOFREE(char *) nodename = NULL;
+ g_autofree char *nodename = NULL;
int rc;
if (!virStorageSourceIsEmpty(oldsrc) &&
VIR_AUTOPTR(qemuBlockStorageSourceChainData) data = NULL;
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
VIR_AUTOPTR(virJSONValue) corProps = NULL;
- VIR_AUTOFREE(char *) corAlias = NULL;
+ g_autofree char *corAlias = NULL;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
{
int ret = -1;
const char* type = virDomainControllerTypeToString(controller->type);
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_CONTROLLER,
{ .controller = controller } };
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_NET, { .net = net } };
virErrorPtr originalError = NULL;
- VIR_AUTOFREE(char *) slirpfdName = NULL;
+ g_autofree char *slirpfdName = NULL;
int slirpfd = -1;
char **tapfdName = NULL;
int *tapfd = NULL;
int *vhostfd = NULL;
size_t vhostfdSize = 0;
size_t queueSize = 0;
- VIR_AUTOFREE(char *) nicstr = NULL;
- VIR_AUTOFREE(char *) netstr = NULL;
+ g_autofree char *nicstr = NULL;
+ g_autofree char *netstr = NULL;
int ret = -1;
bool releaseaddr = false;
bool iface_connected = false;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
virDomainCCWAddressSetPtr ccwaddrs = NULL;
size_t i;
- VIR_AUTOFREE(char *) charDevAlias = NULL;
+ g_autofree char *charDevAlias = NULL;
bool charDevPlugged = false;
bool netdevPlugged = false;
- VIR_AUTOFREE(char *) netdev_name = NULL;
+ g_autofree char *netdev_name = NULL;
virConnectPtr conn = NULL;
virErrorPtr save_err = NULL;
{ .hostdev = hostdev } };
virDomainDeviceInfoPtr info = hostdev->info;
int ret;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
bool releaseaddr = false;
bool teardowncgroup = false;
bool teardownlabel = false;
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virErrorPtr orig_err;
- VIR_AUTOFREE(char *) secAlias = NULL;
+ g_autofree char *secAlias = NULL;
if (!tlsProps && !secProps)
return 0;
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) tlsAlias = NULL;
- VIR_AUTOFREE(char *) secAlias = NULL;
+ g_autofree char *tlsAlias = NULL;
+ g_autofree char *secAlias = NULL;
if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP ||
dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES) {
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
- VIR_AUTOFREE(char *) charAlias = NULL;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *charAlias = NULL;
+ g_autofree char *devstr = NULL;
bool chardevAdded = false;
- VIR_AUTOFREE(char *) tlsAlias = NULL;
+ g_autofree char *tlsAlias = NULL;
const char *secAlias = NULL;
bool need_release = false;
virErrorPtr orig_err;
qemuDomainObjPrivatePtr priv = vm->privateData;
virErrorPtr orig_err;
virDomainDefPtr vmdef = vm->def;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
virDomainChrSourceDefPtr dev = chr->source;
- VIR_AUTOFREE(char *)charAlias = NULL;
+ g_autofree char *charAlias = NULL;
bool chardevAttached = false;
bool teardowncgroup = false;
bool teardowndevice = false;
bool teardownlabel = false;
- VIR_AUTOFREE(char *) tlsAlias = NULL;
+ g_autofree char *tlsAlias = NULL;
const char *secAlias = NULL;
bool need_release = false;
bool guestfwd = false;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_RNG, { .rng = rng } };
virErrorPtr orig_err;
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) charAlias = NULL;
- VIR_AUTOFREE(char *) objAlias = NULL;
- VIR_AUTOFREE(char *) tlsAlias = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *charAlias = NULL;
+ g_autofree char *objAlias = NULL;
+ g_autofree char *tlsAlias = NULL;
const char *secAlias = NULL;
bool releaseaddr = false;
bool teardowncgroup = false;
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
unsigned long long newmem = oldmem + mem->size;
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) objalias = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *objalias = NULL;
bool objAdded = false;
bool teardownlabel = false;
bool teardowncgroup = false;
virDomainHostdevDefPtr hostdev)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
bool added = false;
bool teardowncgroup = false;
bool teardownlabel = false;
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
virErrorPtr orig_err;
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) drvstr = NULL;
- VIR_AUTOFREE(char *) drivealias = NULL;
- VIR_AUTOFREE(char *) secobjAlias = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *drvstr = NULL;
+ g_autofree char *drivealias = NULL;
+ g_autofree char *secobjAlias = NULL;
bool teardowncgroup = false;
bool teardownlabel = false;
bool teardowndevice = false;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
{ .hostdev = hostdev } };
virDomainCCWAddressSetPtr ccwaddrs = NULL;
- VIR_AUTOFREE(char *) vhostfdName = NULL;
+ g_autofree char *vhostfdName = NULL;
int vhostfd = -1;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
bool teardowncgroup = false;
bool teardownlabel = false;
bool teardowndevice = false;
virDomainHostdevDefPtr hostdev)
{
int ret = -1;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
bool added = false;
bool teardowncgroup = false;
bool teardownlabel = false;
virDomainShmemDefPtr shmem)
{
int ret = -1;
- VIR_AUTOFREE(char *) shmstr = NULL;
- VIR_AUTOFREE(char *) charAlias = NULL;
- VIR_AUTOFREE(char *) memAlias = NULL;
+ g_autofree char *shmstr = NULL;
+ g_autofree char *charAlias = NULL;
+ g_autofree char *memAlias = NULL;
bool release_backing = false;
bool release_address = true;
virErrorPtr orig_err = NULL;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } };
virDomainWatchdogAction actualAction = watchdog->action;
const char *actionStr = NULL;
- VIR_AUTOFREE(char *) watchdogstr = NULL;
+ g_autofree char *watchdogstr = NULL;
bool releaseAddress = false;
int rv;
virDomainInputDefPtr input)
{
int ret = -1;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *devstr = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT,
{ .input = input } };
virErrorPtr originalError = NULL;
const char *fdprefix = "vsockfd";
bool releaseaddr = false;
- VIR_AUTOFREE(char *) fdname = NULL;
- VIR_AUTOFREE(char *) devstr = NULL;
+ g_autofree char *fdname = NULL;
+ g_autofree char *devstr = NULL;
int ret = -1;
if (vm->def->vsock) {
qemuDomainObjPrivatePtr priv = vm->privateData;
time_t now = time(NULL);
const char *expire;
- VIR_AUTOFREE(char *) validTo = NULL;
+ g_autofree char *validTo = NULL;
const char *connected = NULL;
const char *password;
int ret = -1;
virDomainDeviceDef dev;
size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) corAlias = NULL;
+ g_autofree char *corAlias = NULL;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
int ret = -1;
qemuDomainObjPrivatePtr priv = vm->privateData;
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
unsigned long long newmem = oldmem - mem->size;
- VIR_AUTOFREE(char *) backendAlias = NULL;
+ g_autofree char *backendAlias = NULL;
int rc;
int idx;
virDomainNetDefPtr net = NULL;
size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) drivealias = NULL;
- VIR_AUTOFREE(char *) objAlias = NULL;
+ g_autofree char *drivealias = NULL;
+ g_autofree char *objAlias = NULL;
bool is_vfio = false;
VIR_DEBUG("Removing host device %s from domain %p %s",
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) hostnet_name = NULL;
- VIR_AUTOFREE(char *) charDevAlias = NULL;
+ g_autofree char *hostnet_name = NULL;
+ g_autofree char *charDevAlias = NULL;
size_t i;
int actualType = virDomainNetGetActualType(net);
bool monitor)
{
virObjectEventPtr event;
- VIR_AUTOFREE(char *) charAlias = NULL;
+ g_autofree char *charAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
int rc = 0;
virDomainObjPtr vm,
virDomainRNGDefPtr rng)
{
- VIR_AUTOFREE(char *) charAlias = NULL;
- VIR_AUTOFREE(char *) objAlias = NULL;
+ g_autofree char *charAlias = NULL;
+ g_autofree char *objAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
ssize_t idx;
int rc = 0;
{
int rc;
ssize_t idx = -1;
- VIR_AUTOFREE(char *) charAlias = NULL;
- VIR_AUTOFREE(char *) memAlias = NULL;
+ g_autofree char *charAlias = NULL;
+ g_autofree char *memAlias = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_DEBUG("Removing shmem device %s from domain %p %s",
virDomainRedirdevDefPtr dev)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- VIR_AUTOFREE(char *) charAlias = NULL;
+ g_autofree char *charAlias = NULL;
ssize_t idx;
VIR_DEBUG("Removing redirdev device %s from domain %p %s",
{
virDomainDeviceInfoPtr info;
virObjectEventPtr event;
- VIR_AUTOFREE(char *) alias = NULL;
+ g_autofree char *alias = NULL;
/*
* save the alias to use when sending a DEVICE_REMOVED event after
return 0;
while ((rc = virDirRead(dirp, &ent, dir)) > 0) {
- VIR_AUTOFREE(char *) filename = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *filename = NULL;
+ g_autofree char *path = NULL;
struct stat sb;
if (STRPREFIX(ent->d_name, "."))
bool privileged)
{
VIR_AUTOPTR(virHashTable) files = NULL;
- VIR_AUTOFREE(char *) homeConfig = NULL;
- VIR_AUTOFREE(char *) xdgConfig = NULL;
- VIR_AUTOFREE(char *) sysLocation = virFileBuildPath(QEMU_SYSTEM_LOCATION, name, NULL);
- VIR_AUTOFREE(char *) etcLocation = virFileBuildPath(QEMU_ETC_LOCATION, name, NULL);
- VIR_AUTOFREE(virHashKeyValuePairPtr) pairs = NULL;
+ g_autofree char *homeConfig = NULL;
+ g_autofree char *xdgConfig = NULL;
+ g_autofree char *sysLocation = virFileBuildPath(QEMU_SYSTEM_LOCATION, name, NULL);
+ g_autofree char *etcLocation = virFileBuildPath(QEMU_ETC_LOCATION, name, NULL);
+ g_autofree virHashKeyValuePairPtr pairs = NULL;
virHashKeyValuePairPtr tmp = NULL;
*configs = NULL;
return -1;
if (!xdgConfig) {
- VIR_AUTOFREE(char *) home = virGetUserDirectory();
+ g_autofree char *home = virGetUserDirectory();
if (!home)
return -1;
unsigned long long mirror_speed,
bool mirror_shallow)
{
- VIR_AUTOFREE(char *) nbd_dest = NULL;
+ g_autofree char *nbd_dest = NULL;
int mon_ret;
if (strchr(host, ':')) {
const char *videoName)
{
int rc = -1;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
QEMU_CHECK_MONITOR(mon);
const char *videoName)
{
int rc = -1;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
QEMU_CHECK_MONITOR(mon);
qemuMonitorJSONBlockStatsCollectData(virJSONValuePtr dev,
int *nstats)
{
- VIR_AUTOFREE(qemuBlockStatsPtr) bstats = NULL;
+ g_autofree qemuBlockStatsPtr bstats = NULL;
virJSONValuePtr parent;
virJSONValuePtr parentstats;
virJSONValuePtr stats;
virHashTablePtr hash,
bool backingChain)
{
- VIR_AUTOFREE(qemuBlockStatsPtr) bstats = NULL;
+ g_autofree qemuBlockStatsPtr bstats = NULL;
int nstats = 0;
const char *qdevname = NULL;
const char *nodename = NULL;
- VIR_AUTOFREE(char *) devicename = NULL;
+ g_autofree char *devicename = NULL;
virJSONValuePtr backing;
if (dev_name &&
return -1;
if (n > 0) {
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
str = virStringListJoin((const char **)features, ", ");
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
{
VIR_AUTOPTR(qemuSlirp) slirp = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOPTR(virJSONValue) doc = NULL;
virJSONValuePtr featuresJSON;
size_t i, nfeatures;
const virDomainDef *def,
const char *alias)
{
- VIR_AUTOFREE(char *) shortName = NULL;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *shortName = NULL;
+ g_autofree char *name = NULL;
if (!(shortName = virDomainDefGetShortName(def)) ||
virAsprintf(&name, "%s-%s-slirp", shortName, alias) < 0)
const virDomainDef *def,
const char *alias)
{
- VIR_AUTOFREE(char *) shortName = NULL;
+ g_autofree char *shortName = NULL;
char *path = NULL;
if (!(shortName = virDomainDefGetShortName(def)) ||
bool hot)
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- VIR_AUTOFREE(char *) pidfile = NULL;
- VIR_AUTOFREE(char *) dbus_path = NULL;
- VIR_AUTOFREE(char *) id = qemuSlirpGetDBusVMStateId(net);
+ g_autofree char *pidfile = NULL;
+ g_autofree char *dbus_path = NULL;
+ g_autofree char *id = qemuSlirpGetDBusVMStateId(net);
virErrorPtr orig_err;
pid_t pid;
int rc;
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) pidfile = NULL;
- VIR_AUTOFREE(char *) dbus_path = NULL;
- VIR_AUTOFREE(char *) dbus_addr = NULL;
- VIR_AUTOFREE(char *) id = NULL;
+ g_autofree char *pidfile = NULL;
+ g_autofree char *dbus_path = NULL;
+ g_autofree char *dbus_addr = NULL;
+ g_autofree char *id = NULL;
size_t i;
const unsigned long long timeout = 5 * 1000; /* ms */
pid_t pid = (pid_t) -1;
for (i = 0; i < net->guestIP.nips; i++) {
const virNetDevIPAddr *ip = net->guestIP.ips[i];
- VIR_AUTOFREE(char *) addr = NULL;
+ g_autofree char *addr = NULL;
const char *opt = "";
if (!(addr = virSocketAddrFormat(&ip->address)))
if (ip->prefix) {
if (VIR_SOCKET_ADDR_IS_FAMILY(&ip->address, AF_INET)) {
virSocketAddr netmask;
- VIR_AUTOFREE(char *) netmaskStr = NULL;
+ g_autofree char *netmaskStr = NULL;
if (virSocketAddrPrefixToNetmask(ip->prefix, &netmask, AF_INET) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
pid_t *pid)
{
int ret;
- VIR_AUTOFREE(char *) swtpm = virTPMGetSwtpm();
+ g_autofree char *swtpm = virTPMGetSwtpm();
char *pidfile = qemuTPMEmulatorCreatePidFilename(swtpmStateDir,
shortName);
if (!pidfile)
int ret = -1;
int pipefd[2] = { -1, -1 };
virConnectPtr conn;
- VIR_AUTOFREE(uint8_t *) secret = NULL;
+ g_autofree uint8_t *secret = NULL;
size_t secret_len;
virSecretLookupTypeDef seclookupdef = {
.type = VIR_SECRET_LOOKUP_TYPE_UUID,
int ret = -1;
char uuid[VIR_UUID_STRING_BUFLEN];
char *vmid = NULL;
- VIR_AUTOFREE(char *)swtpm_setup = virTPMGetSwtpmSetup();
+ g_autofree char *swtpm_setup = virTPMGetSwtpmSetup();
VIR_AUTOCLOSE pwdfile_fd = -1;
if (!swtpm_setup)
virCommandPtr cmd = NULL;
bool created = false;
char *pidfile;
- VIR_AUTOFREE(char *) swtpm = virTPMGetSwtpm();
+ g_autofree char *swtpm = virTPMGetSwtpm();
VIR_AUTOCLOSE pwdfile_fd = -1;
VIR_AUTOCLOSE migpwdfile_fd = -1;
const unsigned char *secretuuid = NULL;
virCommandPtr cmd;
char *pathname;
char *errbuf = NULL;
- VIR_AUTOFREE(char *) swtpm_ioctl = virTPMGetSwtpmIoctl();
+ g_autofree char *swtpm_ioctl = virTPMGetSwtpmIoctl();
if (!swtpm_ioctl)
return;
qemuVhostUserPtr
qemuVhostUserParse(const char *path)
{
- VIR_AUTOFREE(char *) cont = NULL;
+ g_autofree char *cont = NULL;
VIR_AUTOPTR(virJSONValue) doc = NULL;
VIR_AUTOPTR(qemuVhostUser) vu = NULL;
qemuVhostUserPtr ret = NULL;
for (i = 0; i < nvus; i++) {
VIR_AUTOPTR(virJSONValue) doc = NULL;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
vu = vus[i];
const char *shortName,
const char *alias)
{
- VIR_AUTOFREE(char *) devicename = NULL;
+ g_autofree char *devicename = NULL;
if (virAsprintf(&devicename, "%s-%s-vhost-user-gpu", shortName, alias) < 0)
return NULL;
const char *alias,
pid_t *pid)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias);
if (!pidfile)
virDomainVideoDefPtr video)
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- VIR_AUTOFREE(char *) shortname = NULL;
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *shortname = NULL;
+ g_autofree char *pidfile = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
int pair[2] = { -1, -1 };
int cmdret = 0, rc;
virDomainVideoDefPtr video)
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- VIR_AUTOFREE(char *) pidfile = NULL;
- VIR_AUTOFREE(char *) shortname = NULL;
+ g_autofree char *pidfile = NULL;
+ g_autofree char *shortname = NULL;
virErrorPtr orig_err;
shortname = virDomainDefGetShortName(vm->def);
virCgroupPtr cgroup)
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- VIR_AUTOFREE(char *) shortname = NULL;
+ g_autofree char *shortname = NULL;
int rc;
pid_t pid;
ssize_t i;
for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) {
- VIR_AUTOFREE(char *) daemonname = NULL;
- VIR_AUTOFREE(char *) daemonpath = NULL;
+ g_autofree char *daemonname = NULL;
+ g_autofree char *daemonpath = NULL;
if (virAsprintf(&daemonname, "virt%sd", drivers[i]) < 0)
return -1;
ssize_t i;
for (i = 0; i < (ssize_t) G_N_ELEMENTS(drivers) && !*probeduri; i++) {
- VIR_AUTOFREE(char *) sockname = NULL;
+ g_autofree char *sockname = NULL;
if (virAsprintf(&sockname, "%s/libvirt/virt%sd-%s",
RUNSTATEDIR, drivers[i],
{
const char *name;
#ifdef VIRTPROXYD
- VIR_AUTOFREE(char *) probeduri = NULL;
+ g_autofree char *probeduri = NULL;
#endif
unsigned int flags;
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
unsigned int flags)
{
char *sockname = NULL;
- VIR_AUTOFREE(char *) userdir = NULL;
+ g_autofree char *userdir = NULL;
if (flags & VIR_DRV_OPEN_REMOTE_USER) {
if (transport != REMOTE_DRIVER_TRANSPORT_UNIX) {
unsigned int flags)
{
char *sock_name = NULL;
- VIR_AUTOFREE(char *) direct_daemon = NULL;
- VIR_AUTOFREE(char *) legacy_daemon = NULL;
- VIR_AUTOFREE(char *) direct_sock_name = NULL;
- VIR_AUTOFREE(char *) legacy_sock_name = NULL;
+ g_autofree char *direct_daemon = NULL;
+ g_autofree char *legacy_daemon = NULL;
+ g_autofree char *direct_sock_name = NULL;
+ g_autofree char *legacy_sock_name = NULL;
if (driver &&
virAsprintf(&direct_daemon, "virt%sd", driver) < 0)
{
int transport;
#ifndef WIN32
- VIR_AUTOFREE(char *) daemonPath = NULL;
+ g_autofree char *daemonPath = NULL;
#endif
- VIR_AUTOFREE(char *) tls_priority = NULL;
- VIR_AUTOFREE(char *) name = NULL;
- VIR_AUTOFREE(char *) command = NULL;
- VIR_AUTOFREE(char *) sockname = NULL;
- VIR_AUTOFREE(char *) netcat = NULL;
- VIR_AUTOFREE(char *) port = NULL;
- VIR_AUTOFREE(char *) authtype = NULL;
- VIR_AUTOFREE(char *) username = NULL;
- VIR_AUTOFREE(char *) pkipath = NULL;
- VIR_AUTOFREE(char *) keyfile = NULL;
- VIR_AUTOFREE(char *) sshauth = NULL;
- VIR_AUTOFREE(char *) knownHostsVerify = NULL;
- VIR_AUTOFREE(char *) knownHosts = NULL;
- VIR_AUTOFREE(char *) mode_str = NULL;
- VIR_AUTOFREE(char *) daemon_name = NULL;
+ g_autofree char *tls_priority = NULL;
+ g_autofree char *name = NULL;
+ g_autofree char *command = NULL;
+ g_autofree char *sockname = NULL;
+ g_autofree char *netcat = NULL;
+ g_autofree char *port = NULL;
+ g_autofree char *authtype = NULL;
+ g_autofree char *username = NULL;
+ g_autofree char *pkipath = NULL;
+ g_autofree char *keyfile = NULL;
+ g_autofree char *sshauth = NULL;
+ g_autofree char *knownHostsVerify = NULL;
+ g_autofree char *knownHosts = NULL;
+ g_autofree char *mode_str = NULL;
+ g_autofree char *daemon_name = NULL;
bool sanity = true;
bool verify = true;
#ifndef WIN32
"%s/libvirt/secrets", RUNSTATEDIR) < 0)
goto error;
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
- VIR_AUTOFREE(char *) cfgdir = NULL;
+ g_autofree char *rundir = NULL;
+ g_autofree char *cfgdir = NULL;
if (!(cfgdir = virGetUserConfigDirectory()))
goto error;
virSecurityValidateTimestamp(const char *name,
const char *path)
{
- VIR_AUTOFREE(char *) expected_timestamp = NULL;
- VIR_AUTOFREE(char *) timestamp_name = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *expected_timestamp = NULL;
+ g_autofree char *timestamp_name = NULL;
+ g_autofree char *value = NULL;
if (!(expected_timestamp = virSecurityGetTimestamp()) ||
!(timestamp_name = virSecurityGetTimestampAttrName(name)))
virSecurityAddTimestamp(const char *name,
const char *path)
{
- VIR_AUTOFREE(char *) timestamp_name = NULL;
- VIR_AUTOFREE(char *) timestamp_value = NULL;
+ g_autofree char *timestamp_name = NULL;
+ g_autofree char *timestamp_value = NULL;
if (!(timestamp_value = virSecurityGetTimestamp()) ||
!(timestamp_name = virSecurityGetTimestampAttrName(name)))
virSecurityRemoveTimestamp(const char *name,
const char *path)
{
- VIR_AUTOFREE(char *) timestamp_name = NULL;
+ g_autofree char *timestamp_name = NULL;
if (!(timestamp_name = virSecurityGetTimestampAttrName(name)))
return -1;
const char *path,
char **label)
{
- VIR_AUTOFREE(char *) ref_name = NULL;
- VIR_AUTOFREE(char *) attr_name = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *ref_name = NULL;
+ g_autofree char *attr_name = NULL;
+ g_autofree char *value = NULL;
unsigned int refcount = 0;
*label = NULL;
const char *path,
const char *label)
{
- VIR_AUTOFREE(char *) ref_name = NULL;
- VIR_AUTOFREE(char *) attr_name = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *ref_name = NULL;
+ g_autofree char *attr_name = NULL;
+ g_autofree char *value = NULL;
unsigned int refcount = 0;
if (!(ref_name = virSecurityGetRefCountAttrName(name)))
const char *src,
const char *dst)
{
- VIR_AUTOFREE(char *) ref_name = NULL;
- VIR_AUTOFREE(char *) ref_value = NULL;
- VIR_AUTOFREE(char *) attr_name = NULL;
- VIR_AUTOFREE(char *) attr_value = NULL;
- VIR_AUTOFREE(char *) timestamp_name = NULL;
- VIR_AUTOFREE(char *) timestamp_value = NULL;
+ g_autofree char *ref_name = NULL;
+ g_autofree char *ref_value = NULL;
+ g_autofree char *attr_name = NULL;
+ g_autofree char *attr_value = NULL;
+ g_autofree char *timestamp_name = NULL;
+ g_autofree char *timestamp_value = NULL;
if (!(ref_name = virSecurityGetRefCountAttrName(name)) ||
!(attr_name = virSecurityGetAttrName(name)) ||
const char *regfunc,
bool forceload)
{
- VIR_AUTOFREE(char *) modfile = NULL;
+ g_autofree char *modfile = NULL;
if (!(modfile = virFileFindResourceFull(name,
"libvirt_storage_backend_",
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
char *tmp, *partname;
bool addVol = false;
- VIR_AUTOFREE(char *) devpath = NULL;
+ g_autofree char *devpath = NULL;
/* Prepended path will be same for all partitions, so we can
* strip the path to form a reasonable pool-unique name
.pool = pool,
.vol = vol,
};
- VIR_AUTOFREE(char *) parthelper_path = NULL;
+ g_autofree char *parthelper_path = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
virStorageBackendDiskReadGeometry(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) parthelper_path = NULL;
+ g_autofree char *parthelper_path = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
if (!(parthelper_path = virFileFindResource("libvirt_parthelper",
char *src_path = def->source.devices[0].path;
char *srcname = last_component(src_path);
bool isDevMapperDevice;
- VIR_AUTOFREE(char *) devpath = NULL;
+ g_autofree char *devpath = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
virCheckFlags(0, -1);
unsigned long long startOffset = 0, endOffset = 0;
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
virErrorPtr save_err;
- VIR_AUTOFREE(char *)partFormat = NULL;
+ g_autofree char *partFormat = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
cmd = virCommandNewArgList(PARTED,
struct mntent ent;
char buf[1024];
int rc1, rc2;
- VIR_AUTOFREE(char *) src = NULL;
+ g_autofree char *src = NULL;
if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) {
virReportSystemError(errno,
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
int rc;
- VIR_AUTOFREE(char *) src = NULL;
+ g_autofree char *src = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
if (virStorageBackendFileSystemIsValid(pool) < 0)
int nnodes;
size_t i;
int ret = -1;
- VIR_AUTOFREE(xmlNodePtr *)nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
nnodes = virXPathNodeSet("./fs:mount_opts/fs:option", ctxt, &nodes);
if (nnodes < 0)
if (glfs_set_volfile_server(ret->vol, "tcp",
ret->uri->server, ret->uri->port) < 0 ||
glfs_init(ret->vol) < 0) {
- VIR_AUTOFREE(char *) uri = NULL;
+ g_autofree char *uri = NULL;
uri = virURIFormat(ret->uri);
virReportSystemError(errno, _("failed to connect to %s"), NULLSTR(uri));
goto error;
const char *name)
{
char *tmp;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_FREE(vol->key);
VIR_FREE(vol->target.path);
int backingFormat;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL;
- VIR_AUTOFREE(char *) header = NULL;
+ g_autofree char *header = NULL;
*volptr = NULL;
const char *session)
{
uint32_t host;
- VIR_AUTOFREE(char *) sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
if (virAsprintf(&sysfs_path,
"/sys/class/iscsi_session/session%s/device", session) < 0)
.nsources = 0,
.sources = NULL
};
- VIR_AUTOFREE(char *) portal = NULL;
+ g_autofree char *portal = NULL;
VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
int ret = -1;
- VIR_AUTOFREE(char *) session = NULL;
+ g_autofree char *session = NULL;
*isActive = false;
virStorageBackendISCSIStartPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) portal = NULL;
- VIR_AUTOFREE(char *) session = NULL;
+ g_autofree char *portal = NULL;
+ g_autofree char *session = NULL;
if (def->source.nhost != 1) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
virStorageBackendISCSIRefreshPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) session = NULL;
+ g_autofree char *session = NULL;
def->allocation = def->capacity = def->available = 0;
virStorageBackendISCSIStopPool(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) portal = NULL;
- VIR_AUTOFREE(char *) session = NULL;
+ g_autofree char *portal = NULL;
+ g_autofree char *session = NULL;
if ((session = virStorageBackendISCSISession(pool, true)) == NULL)
return 0;
}
for (tmp_addr = addr; tmp_addr; tmp_addr = tmp_addr->next) {
- VIR_AUTOFREE(char *) target = NULL;
+ g_autofree char *target = NULL;
if (VIR_STRDUP(target, tmp_addr->target_name) < 0)
goto cleanup;
.nsources = 0,
.sources = NULL
};
- VIR_AUTOFREE(char *) portal = NULL;
+ g_autofree char *portal = NULL;
VIR_AUTOPTR(virStoragePoolSource) source = NULL;
virCheckFlags(0, NULL);
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
struct iscsi_context *iscsi = NULL;
- VIR_AUTOFREE(char *) portal = NULL;
+ g_autofree char *portal = NULL;
if (!(iscsi = virISCSIDirectCreateContext(def->source.initiator.iqn)))
goto error;
{
struct iscsi_context *iscsi = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) portal = NULL;
+ g_autofree char *portal = NULL;
if (!(iscsi = virStorageBackendISCSIDirectSetConnection(pool, &portal)))
return -1;
struct scsi_task *task = NULL;
int lun = 0;
int ret = -1;
- VIR_AUTOFREE(unsigned char *) data = NULL;
+ g_autofree unsigned char *data = NULL;
if (virStorageBackendISCSIDirectGetLun(vol, &lun) < 0)
return ret;
int err, nvars;
unsigned long long offset, size, length;
virStorageVolSourceExtent extent;
- VIR_AUTOFREE(char *) regex = NULL;
- VIR_AUTOFREE(regex_t *) reg = NULL;
- VIR_AUTOFREE(regmatch_t *) vars = NULL;
+ g_autofree char *regex = NULL;
+ g_autofree regex_t *reg = NULL;
+ g_autofree regmatch_t *vars = NULL;
memset(&extent, 0, sizeof(extent));
for (i = 0; i < nextents; i++) {
size_t j;
int len;
- VIR_AUTOFREE(char *) offset_str = NULL;
+ g_autofree char *offset_str = NULL;
j = (i * 2) + 1;
len = vars[j].rm_eo - vars[j].rm_so;
size_t i;
virStoragePoolSourceDevicePtr dev;
virStoragePoolSource *thisSource;
- VIR_AUTOFREE(char *) pvname = NULL;
- VIR_AUTOFREE(char *) vgname = NULL;
+ g_autofree char *pvname = NULL;
+ g_autofree char *vgname = NULL;
if (VIR_STRDUP(pvname, groups[0]) < 0 ||
VIR_STRDUP(vgname, groups[1]) < 0)
int is_mpath = 0;
uint32_t minor = -1;
uint32_t next;
- VIR_AUTOFREE(char *) map_device = NULL;
+ g_autofree char *map_device = NULL;
do {
is_mpath = virStorageBackendIsMultipath(names->name);
int nnodes;
size_t i;
int ret = -1;
- VIR_AUTOFREE(xmlNodePtr *)nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
nnodes = virXPathNodeSet("./rbd:config_opts/rbd:option", ctxt, &nodes);
if (nnodes < 0)
const char *osd_op_timeout = "30";
const char *rbd_default_format = "2";
virConnectPtr conn = NULL;
- VIR_AUTOFREE(char *) mon_buff = NULL;
+ g_autofree char *mon_buff = NULL;
if (authdef) {
VIR_DEBUG("Using cephx authorization, username: %s", authdef->username);
size_t nnames = 0;
int rc;
size_t max_size = 1024;
- VIR_AUTOFREE(char *) namebuf = NULL;
+ g_autofree char *namebuf = NULL;
const char *name;
while (true) {
}
for (name = namebuf; name < namebuf + max_size;) {
- VIR_AUTOFREE(char *) namedup = NULL;
+ g_autofree char *namedup = NULL;
if (STREQ(name, ""))
break;
int snap_count, protected;
size_t i;
rbd_image_t image = NULL;
- VIR_AUTOFREE(rbd_snap_info_t *) snaps = NULL;
+ g_autofree rbd_snap_info_t *snaps = NULL;
if ((r = rbd_open(ioctx, vol->name, &image, NULL)) < 0) {
virReportSystemError(-r, _("failed to open the RBD image '%s'"),
size_t i;
int diff;
rbd_image_info_t info;
- VIR_AUTOFREE(rbd_snap_info_t *) snaps = NULL;
+ g_autofree rbd_snap_info_t *snaps = NULL;
if ((r = rbd_stat(image, &info, sizeof(info))) < 0) {
virReportSystemError(-r, _("failed to stat the RBD image %s"),
uint64_t stripe_unit;
virBuffer snapname = VIR_BUFFER_INITIALIZER;
rbd_image_t image = NULL;
- VIR_AUTOFREE(char *) snapname_buff = NULL;
+ g_autofree char *snapname_buff = NULL;
if ((r = rbd_open(io, origvol, &image, NULL)) < 0) {
virReportSystemError(-r, _("failed to open the RBD image %s"),
int r = -1;
unsigned long long offset = 0;
unsigned long long length;
- VIR_AUTOFREE(char *) writebuf = NULL;
+ g_autofree char *writebuf = NULL;
if (VIR_ALLOC_N(writebuf, info->obj_size * stripe_count) < 0)
return -1;
virStorageBackendSCSITriggerRescan(uint32_t host)
{
VIR_AUTOCLOSE fd = -1;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_DEBUG("Triggering rescan of host %d", host);
unsigned int host_num;
bool retval = false;
virConnectPtr conn = NULL;
- VIR_AUTOFREE(char *) scsi_host_name = NULL;
- VIR_AUTOFREE(char *) vhba_parent = NULL;
+ g_autofree char *scsi_host_name = NULL;
+ g_autofree char *vhba_parent = NULL;
VIR_DEBUG("name=%s, parent_name=%s", name, parent_name);
{
virStoragePoolFCRefreshInfoPtr cbdata = NULL;
virThread thread;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
VIR_DEBUG("configFile='%s' parent='%s', wwnn='%s' wwpn='%s'",
NULLSTR(configFile), NULLSTR(fchost->parent),
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
unsigned int host;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *name = NULL;
*isActive = false;
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
unsigned int host;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
def->allocation = def->capacity = def->available = 0;
virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool)
{
size_t i;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOSTRINGLIST lines = NULL;
VIR_AUTOSTRINGLIST cells = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
static int
virStorageBackendSheepdogRefreshPool(virStoragePoolObjPtr pool)
{
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
cmd = virCommandNewArgList(SHEEPDOGCLI, "node", "info", "-r", NULL);
virStorageBackendVzPoolStart(virStoragePoolObjPtr pool)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) grp_name = NULL;
- VIR_AUTOFREE(char *) usr_name = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *grp_name = NULL;
+ g_autofree char *usr_name = NULL;
+ g_autofree char *mode = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
int ret;
FILE *mtab;
struct mntent ent;
char buf[1024];
- VIR_AUTOFREE(char *) cluster = NULL;
+ g_autofree char *cluster = NULL;
if (virAsprintf(&cluster, "vstorage://%s", def->source.name) < 0)
return -1;
virStorageBackendZFSVolModeNeeded(void)
{
int ret = -1, exit_code = -1;
- VIR_AUTOFREE(char *) error = NULL;
+ g_autofree char *error = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
/* 'zfs get' without arguments prints out
bool *isActive)
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
- VIR_AUTOFREE(char *) devpath = NULL;
+ g_autofree char *devpath = NULL;
if (virAsprintf(&devpath, "/dev/zvol/%s",
def->source.name) < 0)
size_t i;
VIR_AUTOSTRINGLIST lines = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) volumes_list = NULL;
+ g_autofree char *volumes_list = NULL;
/**
* $ zfs list -Hp -t volume -o name,volsize -r test
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
bool active = false;
virStorageBackendPtr backend;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
if ((backend = virStorageBackendForType(def->type)) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
}
if (started) {
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
stateFile = virFileBuildPath(driver->stateDir, def->name, ".xml");
if (!stateFile ||
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{
- VIR_AUTOFREE(char *) configdir = NULL;
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *configdir = NULL;
+ g_autofree char *rundir = NULL;
bool autostart = true;
if (VIR_ALLOC(driver) < 0)
virObjectEventPtr event = NULL;
unsigned int build_flags = 0;
VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD |
VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE |
virObjectEventPtr event = NULL;
int ret = -1;
unsigned int build_flags = 0;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
bool restoreStarting = false;
virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD |
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
if (!(obj = storagePoolObjFindByUUID(pool->uuid, pool->name)))
goto cleanup;
virStorageBackendPtr backend;
virObjectEventPtr event = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
if (!(obj = virStoragePoolObjFromStoragePool(pool)))
return -1;
virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStorageBackendPtr backend;
- VIR_AUTOFREE(char *) stateFile = NULL;
+ g_autofree char *stateFile = NULL;
int ret = -1;
virObjectEventPtr event = NULL;
{
struct storageVolLookupData *data = (struct storageVolLookupData *)opaque;
virStoragePoolDefPtr def;
- VIR_AUTOFREE(char *) stable_path = NULL;
+ g_autofree char *stable_path = NULL;
if (!virStoragePoolObjIsActive(obj))
return false;
virStoragePoolObjPtr obj;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
- VIR_AUTOFREE(char *) cleanpath = NULL;
+ g_autofree char *cleanpath = NULL;
cleanpath = virFileSanitizePath(path);
if (!cleanpath)
virStorageBackendPloopRestoreDesc(char *path)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) refresh_tool = NULL;
- VIR_AUTOFREE(char *) desc = NULL;
+ g_autofree char *refresh_tool = NULL;
+ g_autofree char *desc = NULL;
if (virAsprintf(&desc, "%s/DiskDescriptor.xml", path) < 0)
return -1;
size_t bufsiz = 0;
ssize_t ret;
struct stat st;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
*linkpath = NULL;
virStorageFileBackendGlusterGetUniqueIdentifier(virStorageSourcePtr src)
{
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
- VIR_AUTOFREE(char *) filePath = NULL;
+ g_autofree char *filePath = NULL;
if (priv->canonpath)
return priv->canonpath;
int wbytes = 0;
int interval;
struct stat st;
- VIR_AUTOFREE(char *) zerobuf = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *zerobuf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOCLOSE inputfd = -1;
if ((inputfd = open(inputvol->target.path, O_RDONLY)) < 0) {
int ret = -1;
bool created = false;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) create_tool = NULL;
+ g_autofree char *create_tool = NULL;
virCheckFlags(0, -1);
unsigned long long capacity)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) resize_tool = NULL;
+ g_autofree char *resize_tool = NULL;
resize_tool = virFindFileInPath("ploop");
if (!resize_tool) {
{
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
int accessRetCode = -1;
- VIR_AUTOFREE(char *) absolutePath = NULL;
+ g_autofree char *absolutePath = NULL;
if (info->format == VIR_STORAGE_FILE_RAW) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
virStorageEncryptionInfoDefPtr encinfo,
struct _virStorageBackendQemuImgInfo *info)
{
- VIR_AUTOFREE(char *) opts = NULL;
+ g_autofree char *opts = NULL;
if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0)
return -1;
const char *secretAlias)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) commandStr = NULL;
+ g_autofree char *commandStr = NULL;
virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias);
virQEMUBuildBufferEscapeComma(&buf, secretPath);
const char *secretAlias)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) commandStr = NULL;
+ g_autofree char *commandStr = NULL;
virBufferAsprintf(&buf, "driver=luks,key-secret=%s,file.filename=",
secretAlias);
virStorageEncryptionPtr enc = vol->target.encryption;
virStorageEncryptionPtr inputenc = inputvol ? inputvol->target.encryption : NULL;
virStorageEncryptionInfoDefPtr encinfo = NULL;
- VIR_AUTOFREE(char *) inputSecretAlias = NULL;
+ g_autofree char *inputSecretAlias = NULL;
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
{
int ret = -1;
virStorageVolEncryptConvertStep convertStep = VIR_STORAGE_VOL_ENCRYPT_NONE;
- VIR_AUTOFREE(char *) create_tool = NULL;
- VIR_AUTOFREE(char *) secretPath = NULL;
- VIR_AUTOFREE(char *) inputSecretPath = NULL;
+ g_autofree char *create_tool = NULL;
+ g_autofree char *secretPath = NULL;
+ g_autofree char *inputSecretPath = NULL;
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
static bool
storageBackendIsPloopDir(char *path)
{
- VIR_AUTOFREE(char *) root = NULL;
- VIR_AUTOFREE(char *) desc = NULL;
+ g_autofree char *root = NULL;
+ g_autofree char *desc = NULL;
if (virAsprintf(&root, "%s/root.hds", path) < 0)
return false;
storageBackendRedoPloopUpdate(virStorageSourcePtr target, struct stat *sb,
int *fd, unsigned int flags)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, "%s/root.hds", target->path) < 0)
return -1;
int rc;
struct stat sb;
ssize_t len = VIR_STORAGE_MAX_HEADER;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOCLOSE fd = -1;
if ((rc = virStorageBackendVolOpen(target->path, &sb, openflags)) < 0)
const char *type;
virStorageEncryptionPtr enc = vol->target.encryption;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) img_tool = NULL;
- VIR_AUTOFREE(char *) secretPath = NULL;
- VIR_AUTOFREE(char *) secretAlias = NULL;
+ g_autofree char *img_tool = NULL;
+ g_autofree char *secretPath = NULL;
+ g_autofree char *secretAlias = NULL;
if (enc && (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_QCOW ||
enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT) &&
{
char *snap_tool = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
snap_tool = virFindFileInPath("ploop");
if (!snap_tool) {
char *target_path = vol->target.path;
int has_snap = 0;
bool sparse = flags & VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM;
- VIR_AUTOFREE(char *)path = NULL;
+ g_autofree char *path = NULL;
virCheckFlags(VIR_STORAGE_VOL_UPLOAD_SPARSE_STREAM, -1);
/* if volume has target format VIR_STORAGE_FILE_PLOOP
char *target_path = vol->target.path;
int has_snap = 0;
bool sparse = flags & VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
virCheckFlags(VIR_STORAGE_VOL_DOWNLOAD_SPARSE_STREAM, -1);
if (vol->target.format == VIR_STORAGE_FILE_PLOOP) {
unsigned long long remaining = 0;
off_t size;
size_t write_size = 0;
- VIR_AUTOFREE(char *) writebuf = NULL;
+ g_autofree char *writebuf = NULL;
if (VIR_ALLOC_N(writebuf, writebuf_length) < 0)
return -1;
unsigned int algorithm)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) target_path = NULL;
- VIR_AUTOFREE(char *) disk_desc = NULL;
- VIR_AUTOFREE(char *) create_tool = NULL;
+ g_autofree char *target_path = NULL;
+ g_autofree char *disk_desc = NULL;
+ g_autofree char *create_tool = NULL;
create_tool = virFindFileInPath("ploop");
if (!create_tool) {
mode_t mode;
bool needs_create_as_uid;
unsigned int dir_create_flags;
- VIR_AUTOFREE(char *) parent = NULL;
+ g_autofree char *parent = NULL;
if (VIR_STRDUP(parent, def->target.path) < 0)
return -1;
size_t i;
int nnodes;
int ret = -1;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
- VIR_AUTOFREE(char *) volname = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
+ g_autofree char *volname = NULL;
if (!(doc = virXMLParseStringCtxt(xml, _("(gluster_cli_output)"), &ctxt)))
goto cleanup;
{
int rc;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) glusterpath = NULL;
- VIR_AUTOFREE(char *) outbuf = NULL;
+ g_autofree char *glusterpath = NULL;
+ g_autofree char *outbuf = NULL;
if (!(glusterpath = virFindFileInPath("gluster"))) {
if (report) {
char *start, *end;
int ret = VIR_STORAGE_PARTED_ERROR;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) output = NULL;
- VIR_AUTOFREE(char *) error = NULL;
+ g_autofree char *output = NULL;
+ g_autofree char *error = NULL;
cmd = virCommandNew(PARTED);
virCommandAddArgSet(cmd, args);
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
int retval = -1;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
- VIR_AUTOFREE(char *) devpath = NULL;
+ g_autofree char *devpath = NULL;
/* Check if the pool is using a stable target path. The call to
* virStorageBackendStablePath will fail if the pool target path
struct dirent *block_dirent = NULL;
int retval = -1;
int direrr;
- VIR_AUTOFREE(char *) block_path = NULL;
+ g_autofree char *block_path = NULL;
if (virAsprintf(&block_path, "%s/block", lun_path) < 0)
goto cleanup;
struct dirent *lun_dirent = NULL;
int retval = -1;
int direrr;
- VIR_AUTOFREE(char *) lun_path = NULL;
+ g_autofree char *lun_path = NULL;
*block_device = NULL;
char typestr[3];
char *gottype, *p;
FILE *typefile;
- VIR_AUTOFREE(char *) type_path = NULL;
+ g_autofree char *type_path = NULL;
if (virAsprintf(&type_path, "/sys/bus/scsi/devices/%u:%u:%u:%u/type",
host, bus, target, lun) < 0)
{
int retval = -1;
int device_type;
- VIR_AUTOFREE(char *) block_device = NULL;
+ g_autofree char *block_device = NULL;
VIR_DEBUG("Processing LU %u:%u:%u:%u",
host, bus, target, lun);
virStoragePoolDefPtr def,
const char *providedOpts)
{
- VIR_AUTOFREE(char *) mountOpts = NULL;
+ g_autofree char *mountOpts = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (*default_mount_opts != '\0')
bool cifsfs = (def->type == VIR_STORAGE_POOL_NETFS &&
def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
virCommandPtr cmd = NULL;
- VIR_AUTOFREE(char *) nfsVers = NULL;
+ g_autofree char *nfsVers = NULL;
if (def->type == VIR_STORAGE_POOL_NETFS && def->source.protocolVer > 0 &&
virAsprintf(&nfsVers, "nfsvers=%u", def->source.protocolVer) < 0)
int tmp, n;
size_t i;
unsigned int tmpuint;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
if (VIR_ALLOC(nsdata) < 0)
return -1;
xmlNodePtr ret = NULL;
xmlDocPtr doc = NULL;
char *absFile = NULL;
- VIR_AUTOFREE(char *) relFile = NULL;
+ g_autofree char *relFile = NULL;
if ((relFile = virXMLPropString(node, "file"))) {
absFile = testBuildFilename(file, relFile);
{
long l;
int ret;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
ret = virXPathLong("string(/node/cpu/nodes[1])", ctxt, &l);
if (ret == 0) {
int num, ret = -1;
size_t i;
virDomainObjPtr obj = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/domain", ctxt, &nodes);
if (num < 0)
int num;
size_t i;
virNetworkObjPtr obj;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/network", ctxt, &nodes);
if (num < 0)
int num;
size_t i;
virInterfaceObjPtr obj;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/interface", ctxt, &nodes);
if (num < 0)
virStoragePoolDefPtr def = virStoragePoolObjGetDef(obj);
size_t i;
int num;
- VIR_AUTOFREE(char *) vol_xpath = NULL;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree char *vol_xpath = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
/* Find storage volumes */
int num;
size_t i;
virStoragePoolObjPtr obj;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/pool", ctxt, &nodes);
if (num < 0)
int num;
size_t i;
virNodeDeviceObjPtr obj;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/device", ctxt, &nodes);
if (num < 0)
{
int num;
size_t i;
- VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
+ g_autofree xmlNodePtr *nodes = NULL;
num = virXPathNodeSet("/node/auth/user", ctxt, &nodes);
if (num < 0)
return -1;
for (i = 0; i < num; i++) {
- VIR_AUTOFREE(char *) username = NULL;
+ g_autofree char *username = NULL;
ctxt->node = nodes[i];
username = virXPathString("string(.)", ctxt);
testDriverPtr privconn = conn->privateData;
int ret = -1;
ssize_t i;
- VIR_AUTOFREE(char *) username = NULL;
- VIR_AUTOFREE(char *) password = NULL;
+ g_autofree char *username = NULL;
+ g_autofree char *password = NULL;
virObjectLock(privconn);
if (privconn->numAuths == 0) {
{
int len;
int fd = -1;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
xml = virDomainDefFormat(def, driver->caps, VIR_DOMAIN_DEF_FORMAT_SECURE);
int fd = -1;
int len;
virDomainDefPtr def = NULL;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
if ((fd = open(path, O_RDONLY)) < 0) {
virReportSystemError(errno, _("cannot read domain image '%s'"), path);
virObjectEventPtr event_new = NULL;
virObjectEventPtr event_old = NULL;
int ret = -1;
- VIR_AUTOFREE(char *) new_dom_name = NULL;
+ g_autofree char *new_dom_name = NULL;
virCheckFlags(0, -1);
virDomainObjPtr vm = NULL;
virDomainDefPtr def = NULL;
virDomainNumatuneMemMode mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
- VIR_AUTOFREE(char *) nodeset = NULL;
+ g_autofree char *nodeset = NULL;
int ret = -1;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
virNodeDeviceObjPtr obj = NULL, objcopy = NULL;
virNodeDeviceDefPtr objdef;
virObjectEventPtr event = NULL;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
/* In the real code, we'd call virVHBAManageVport which would take the
* wwnn/wwpn from the input XML in order to call the "vport_create"
virNodeDevicePtr dev = NULL, ret = NULL;
virNodeDeviceObjPtr obj = NULL;
virNodeDeviceDefPtr objdef;
- VIR_AUTOFREE(char *) wwnn = NULL;
- VIR_AUTOFREE(char *) wwpn = NULL;
+ g_autofree char *wwnn = NULL;
+ g_autofree char *wwpn = NULL;
virCheckFlags(0, NULL);
virNodeDeviceObjPtr parentobj = NULL;
virNodeDeviceDefPtr def;
virObjectEventPtr event = NULL;
- VIR_AUTOFREE(char *) wwnn = NULL;
- VIR_AUTOFREE(char *) wwpn = NULL;
+ g_autofree char *wwnn = NULL;
+ g_autofree char *wwpn = NULL;
if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
return -1;
static int
runIO(const char *path, int fd, int oflags)
{
- VIR_AUTOFREE(void *) base = NULL; /* Location to be freed */
+ g_autofree void *base = NULL; /* Location to be freed */
char *buf = NULL; /* Aligned location within base */
size_t buflen = 1024*1024;
intptr_t alignMask = 64*1024 - 1;
{
int num = 0;
int msglen;
- VIR_AUTOFREE(void *) nlData = NULL;
+ g_autofree void *nlData = NULL;
virArpTablePtr table = NULL;
struct nlmsghdr* nh;
struct rtattr * tb[NDA_MAX+1];
continue;
if (tb[NDA_DST]) {
- VIR_AUTOFREE(char *) ipstr = NULL;
+ g_autofree char *ipstr = NULL;
virSocketAddr virAddr;
if (VIR_REALLOC_N(table->t, num + 1) < 0)
goto cleanup;
virAuditRecordType type G_GNUC_UNUSED, bool success,
const char *fmt, ...)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
va_list args;
/* Duplicate later checks, to short circuit & avoid printf overhead
{
size_t i;
const char *authenv = getenv("LIBVIRT_AUTH_FILE");
- VIR_AUTOFREE(char *) userdir = NULL;
+ g_autofree char *userdir = NULL;
*path = NULL;
{
unsigned int ncred;
virConnectCredential cred;
- VIR_AUTOFREE(char *) prompt = NULL;
+ g_autofree char *prompt = NULL;
char *ret = NULL;
if (virAuthGetCredential(servicename, hostname, "username", path, &ret) < 0)
const char *defaultUsername,
const char *hostname)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAuthGetConfigFilePath(conn, &path) < 0)
return NULL;
{
unsigned int ncred;
virConnectCredential cred;
- VIR_AUTOFREE(char *) prompt = NULL;
+ g_autofree char *prompt = NULL;
char *ret = NULL;
if (virAuthGetCredential(servicename, hostname, "password", path, &ret) < 0)
const char *username,
const char *hostname)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAuthGetConfigFilePath(conn, &path) < 0)
return NULL;
const char *credname,
const char **value)
{
- VIR_AUTOFREE(char *) authgroup = NULL;
- VIR_AUTOFREE(char *) credgroup = NULL;
+ g_autofree char *authgroup = NULL;
+ g_autofree char *credgroup = NULL;
const char *authcred;
*value = NULL;
virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
{
int len;
- VIR_AUTOFREE(char *) escaped = NULL;
+ g_autofree char *escaped = NULL;
char *out;
const char *cur;
const char forbidden_characters[] = {
const char *format, const char *str)
{
int len;
- VIR_AUTOFREE(char *) escaped = NULL;
+ g_autofree char *escaped = NULL;
char *out;
const char *cur;
virBufferEscapeShell(virBufferPtr buf, const char *str)
{
int len;
- VIR_AUTOFREE(char *) escaped = NULL;
+ g_autofree char *escaped = NULL;
char *out;
const char *cur;
{
FILE *fp = NULL;
int ret = 0;
- VIR_AUTOFREE(char *) line = NULL;
+ g_autofree char *line = NULL;
size_t buflen;
/* If it starts with 'cgroup.' or a '_' of any
FILE *mapping = NULL;
char line[1024];
int ret = -1;
- VIR_AUTOFREE(char *) procfile = NULL;
+ g_autofree char *procfile = NULL;
VIR_DEBUG("Detecting placement for pid %lld path %s",
(long long) pid, path);
const char *key,
const char *value)
{
- VIR_AUTOFREE(char *) keypath = NULL;
+ g_autofree char *keypath = NULL;
if (virCgroupPathOfController(group, controller, key, &keypath) < 0)
return -1;
const char *key,
char **value)
{
- VIR_AUTOFREE(char *) keypath = NULL;
+ g_autofree char *keypath = NULL;
if (virCgroupPathOfController(group, controller, key, &keypath) < 0)
return -1;
const char *path,
char **value)
{
- VIR_AUTOFREE(char *) prefix = NULL;
+ g_autofree char *prefix = NULL;
char **lines = NULL;
int ret = -1;
const char *key,
unsigned long long int value)
{
- VIR_AUTOFREE(char *) strval = NULL;
+ g_autofree char *strval = NULL;
if (virAsprintf(&strval, "%llu", value) < 0)
return -1;
const char *key,
long long int value)
{
- VIR_AUTOFREE(char *) strval = NULL;
+ g_autofree char *strval = NULL;
if (virAsprintf(&strval, "%lld", value) < 0)
return -1;
const char *key,
long long int *value)
{
- VIR_AUTOFREE(char *) strval = NULL;
+ g_autofree char *strval = NULL;
if (virCgroupGetValueStr(group, controller, key, &strval) < 0)
return -1;
const char *key,
unsigned long long int *value)
{
- VIR_AUTOFREE(char *) strval = NULL;
+ g_autofree char *strval = NULL;
if (virCgroupGetValueStr(group, controller, key, &strval) < 0)
return -1;
virCgroupPtr *group)
{
int ret = -1;
- VIR_AUTOFREE(char *) parentPath = NULL;
- VIR_AUTOFREE(char *) newPath = NULL;
+ g_autofree char *parentPath = NULL;
+ g_autofree char *newPath = NULL;
virCgroupPtr parent = NULL;
VIR_DEBUG("path=%s create=%d controllers=%x",
path, create, controllers);
bool create,
virCgroupPtr *group)
{
- VIR_AUTOFREE(char *)grpname = NULL;
+ g_autofree char *grpname = NULL;
if (virAsprintf(&grpname, "%s.libvirt-%s",
name, driver) < 0)
bool create,
virCgroupPtr *group)
{
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
int controllers;
switch (nameval) {
{
int rv;
virCgroupPtr init;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
size_t i;
VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
virCgroupPtr group_vcpu = NULL;
while ((i = virBitmapNextSetBit(guestvcpus, i)) >= 0) {
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
char *pos;
unsigned long long tmp;
ssize_t j;
size_t i;
int need_cpus, total_cpus;
char *pos;
- VIR_AUTOFREE(char *) buf = NULL;
- VIR_AUTOFREE(unsigned long long *) sum_cpu_time = NULL;
+ g_autofree char *buf = NULL;
+ g_autofree unsigned long long *sum_cpu_time = NULL;
virTypedParameterPtr ent;
int param_idx;
unsigned long long cpu_time;
/* This is best-effort cleanup: we want to log failures with just
* VIR_ERROR instead of normal virReportError */
while ((direrr = virDirRead(grpdir, &ent, NULL)) > 0) {
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (ent->d_type != DT_DIR) continue;
{
int ret = -1;
bool killedAny = false;
- VIR_AUTOFREE(char *) keypath = NULL;
+ g_autofree char *keypath = NULL;
bool done = false;
FILE *fp = NULL;
VIR_DEBUG("group=%p path=%s signum=%d pids=%p",
int ret = -1;
int rc;
bool killedAny = false;
- VIR_AUTOFREE(char *) keypath = NULL;
+ g_autofree char *keypath = NULL;
DIR *dp = NULL;
virCgroupPtr subgroup = NULL;
struct dirent *ent;
const char *machinename)
{
size_t i;
- VIR_AUTOFREE(char *) partname = NULL;
- VIR_AUTOFREE(char *) scopename_old = NULL;
- VIR_AUTOFREE(char *) scopename_new = NULL;
- VIR_AUTOFREE(char *) partmachinename = NULL;
+ g_autofree char *partname = NULL;
+ g_autofree char *scopename_old = NULL;
+ g_autofree char *scopename_new = NULL;
+ g_autofree char *partmachinename = NULL;
if (virAsprintf(&partname, "%s.libvirt-%s",
name, drivername) < 0)
const char *typeStr,
virCgroupV1ControllerPtr controller)
{
- VIR_AUTOFREE(char *) linkSrc = NULL;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *linkSrc = NULL;
+ g_autofree char *tmp = NULL;
char *dirName;
struct stat sb;
VIR_DEBUG("Setting up inheritance %s -> %s", parent->path, group->path);
for (i = 0; i < G_N_ELEMENTS(inherit_values); i++) {
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
if (virCgroupGetValueStr(parent,
VIR_CGROUP_CONTROLLER_CPUSET,
VIR_DEBUG("Make group %s", group->path);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
/* We must never mkdir() in systemd's hierarchy */
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
VIR_DEBUG("Removing cgroup %s", group->path);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- VIR_AUTOFREE(char *) grppath = NULL;
+ g_autofree char *grppath = NULL;
/* Skip over controllers not mounted */
if (!group->legacy[i].mountPoint)
int controller)
{
int ret = -1;
- VIR_AUTOFREE(char *) content = NULL;
+ g_autofree char *content = NULL;
if (!cgroup)
return -1;
const char *mountopts)
{
size_t i;
- VIR_AUTOFREE(char *) opts = NULL;
- VIR_AUTOFREE(char *) root = NULL;
+ g_autofree char *opts = NULL;
+ g_autofree char *root = NULL;
if (!(root = virCgroupV1IdentifyRoot(group)))
return -1;
continue;
if (!virFileExists(group->legacy[i].mountPoint)) {
- VIR_AUTOFREE(char *) src = NULL;
+ g_autofree char *src = NULL;
if (virAsprintf(&src, "%s%s",
oldroot,
group->legacy[i].mountPoint) < 0)
int direrr;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
- VIR_AUTOFREE(char *) base = NULL;
+ g_autofree char *base = NULL;
struct dirent *de;
if (!((1 << i) & controllers))
goto cleanup;
while ((direrr = virDirRead(dh, &de, base)) > 0) {
- VIR_AUTOFREE(char *) entry = NULL;
+ g_autofree char *entry = NULL;
if (virAsprintf(&entry, "%s/%s", base, de->d_name) < 0)
goto cleanup;
virCgroupV1SetBlkioWeight(virCgroupPtr group,
unsigned int weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *value = NULL;
if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
"blkio.bfq.weight", &path) < 0) {
virCgroupV1GetBlkioWeight(virCgroupPtr group,
unsigned int *weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *value = NULL;
if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
"blkio.bfq.weight", &path) < 0) {
long long *requests_write)
{
long long stats_val;
- VIR_AUTOFREE(char *) str1 = NULL;
- VIR_AUTOFREE(char *) str2 = NULL;
+ g_autofree char *str1 = NULL;
+ g_autofree char *str2 = NULL;
char *p1 = NULL;
char *p2 = NULL;
size_t i;
long long *requests_read,
long long *requests_write)
{
- VIR_AUTOFREE(char *) str1 = NULL;
- VIR_AUTOFREE(char *) str2 = NULL;
- VIR_AUTOFREE(char *) str3 = NULL;
+ g_autofree char *str1 = NULL;
+ g_autofree char *str2 = NULL;
+ g_autofree char *str3 = NULL;
char *p1 = NULL;
char *p2 = NULL;
size_t i;
const char *devPath,
unsigned int weight)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
+ g_autofree char *path = NULL;
if (!(blkstr = virCgroupGetBlockDevString(devPath)))
return -1;
const char *devPath,
unsigned int *weight)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
+ g_autofree char *path = NULL;
if (virCgroupV1PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
"blkio.weight_device", &path) < 0) {
const char *path,
unsigned int riops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned int *riops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
if (virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_BLKIO,
const char *path,
unsigned int wiops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned int *wiops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
if (virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_BLKIO,
const char *path,
unsigned long long rbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned long long *rbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
if (virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_BLKIO,
const char *path,
unsigned long long wbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned long long *wbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
if (virCgroupGetValueStr(group,
VIR_CGROUP_CONTROLLER_BLKIO,
int minor,
int perms)
{
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) majorstr = NULL;
- VIR_AUTOFREE(char *) minorstr = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *majorstr = NULL;
+ g_autofree char *minorstr = NULL;
if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) ||
(major >= 0 && virAsprintf(&majorstr, "%i", major) < 0))
int minor,
int perms)
{
- VIR_AUTOFREE(char *) devstr = NULL;
- VIR_AUTOFREE(char *) majorstr = NULL;
- VIR_AUTOFREE(char *) minorstr = NULL;
+ g_autofree char *devstr = NULL;
+ g_autofree char *majorstr = NULL;
+ g_autofree char *minorstr = NULL;
if ((major < 0 && VIR_STRDUP(majorstr, "*") < 0) ||
(major >= 0 && virAsprintf(&majorstr, "%i", major) < 0))
static bool
virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (!cgroup)
return false;
unsigned long long *user,
unsigned long long *sys)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
char *p;
static double scale = -1.0;
return false;
while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) {
- VIR_AUTOFREE(char *) contFile = NULL;
- VIR_AUTOFREE(char *) contStr = NULL;
+ g_autofree char *contFile = NULL;
+ g_autofree char *contStr = NULL;
if (STRNEQ(entry.mnt_type, "cgroup2"))
continue;
const char *drivername,
const char *machinename)
{
- VIR_AUTOFREE(char *) partmachinename = NULL;
- VIR_AUTOFREE(char *) scopename = NULL;
+ g_autofree char *partmachinename = NULL;
+ g_autofree char *scopename = NULL;
char *tmp;
if (virAsprintf(&partmachinename, "%s.libvirt-%s", machinename,
virCgroupPtr parent)
{
int rc;
- VIR_AUTOFREE(char *) contStr = NULL;
- VIR_AUTOFREE(char *) contFile = NULL;
+ g_autofree char *contStr = NULL;
+ g_autofree char *contFile = NULL;
char **contList = NULL;
char **tmp;
int controller,
bool report)
{
- VIR_AUTOFREE(char *) val = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *val = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&val, "+%s",
virCgroupV2ControllerTypeToString(controller)) < 0) {
bool create,
unsigned int flags)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
int controller;
if (flags & VIR_CGROUP_SYSTEMD) {
static int
virCgroupV2Remove(virCgroupPtr group)
{
- VIR_AUTOFREE(char *) grppath = NULL;
+ g_autofree char *grppath = NULL;
int controller;
/* Don't delete the root group, if we accidentally
int controller)
{
int ret = -1;
- VIR_AUTOFREE(char *) content = NULL;
+ g_autofree char *content = NULL;
ret = virCgroupGetValueStr(cgroup, controller, "cgroup.procs", &content);
const char *oldroot,
const char *mountopts)
{
- VIR_AUTOFREE(char *) opts = NULL;
- VIR_AUTOFREE(char *) src = NULL;
+ g_autofree char *opts = NULL;
+ g_autofree char *src = NULL;
VIR_DEBUG("Mounting cgroups at '%s'", group->unified.mountPoint);
gid_t gid,
int controllers G_GNUC_UNUSED)
{
- VIR_AUTOFREE(char *) base = NULL;
+ g_autofree char *base = NULL;
if (virAsprintf(&base, "%s%s", cgroup->unified.mountPoint,
cgroup->unified.placement) < 0) {
virCgroupV2SetBlkioWeight(virCgroupPtr group,
unsigned int weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *value = NULL;
const char *format = "%u";
if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
virCgroupV2GetBlkioWeight(virCgroupPtr group,
unsigned int *weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *value = NULL;
char *tmp;
if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
long long *requests_write)
{
long long stats_val;
- VIR_AUTOFREE(char *) str1 = NULL;
+ g_autofree char *str1 = NULL;
char *p1;
size_t i;
long long *requests_read,
long long *requests_write)
{
- VIR_AUTOFREE(char *) str1 = NULL;
- VIR_AUTOFREE(char *) str2 = NULL;
+ g_autofree char *str1 = NULL;
+ g_autofree char *str2 = NULL;
char *p1;
size_t i;
const char *devPath,
unsigned int weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(devPath)))
return -1;
const char *devPath,
unsigned int *weight)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
char *tmp;
if (virCgroupV2PathOfController(group, VIR_CGROUP_CONTROLLER_BLKIO,
const char *path,
unsigned int riops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned int *riops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
const char *name = "riops=";
char *tmp;
const char *path,
unsigned int wiops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned int *wiops)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
const char *name = "wiops=";
char *tmp;
const char *path,
unsigned long long rbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned long long *rbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
const char *name = "rbps=";
char *tmp;
const char *path,
unsigned long long wbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) blkstr = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *blkstr = NULL;
if (!(blkstr = virCgroupGetBlockDevString(path)))
return -1;
const char *path,
unsigned long long *wbps)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *value = NULL;
const char *name = "wbps=";
char *tmp;
unsigned long long *inactiveFile,
unsigned long long *unevictable)
{
- VIR_AUTOFREE(char *) stat = NULL;
+ g_autofree char *stat = NULL;
char *line = NULL;
unsigned long long cacheVal = 0;
unsigned long long activeAnonVal = 0;
virCgroupV2GetMemoryHardLimit(virCgroupPtr group,
unsigned long long *kb)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
unsigned long long max;
if (virCgroupGetValueStr(group,
virCgroupV2GetMemorySoftLimit(virCgroupPtr group,
unsigned long long *kb)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
unsigned long long high;
if (virCgroupGetValueStr(group,
virCgroupV2GetMemSwapHardLimit(virCgroupPtr group,
unsigned long long *kb)
{
- VIR_AUTOFREE(char *) value = NULL;
+ g_autofree char *value = NULL;
unsigned long long max;
if (virCgroupGetValueStr(group,
virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
unsigned long long cfs_period)
{
- VIR_AUTOFREE(char *) value = NULL;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *value = NULL;
+ g_autofree char *str = NULL;
char *tmp;
/* The cfs_period should be greater or equal than 1ms, and less or equal
virCgroupV2GetCpuCfsPeriod(virCgroupPtr group,
unsigned long long *cfs_period)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
char *tmp;
if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU,
virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
long long *cfs_quota)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
char *tmp;
if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU,
static bool
virCgroupV2SupportsCpuBW(virCgroupPtr cgroup)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virCgroupV2PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
"cpu.max", &path) < 0) {
virCgroupV2GetCpuacctUsage(virCgroupPtr group,
unsigned long long *usage)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
char *tmp;
if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPUACCT,
unsigned long long *user,
unsigned long long *sys)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
char *tmp;
unsigned long long userVal = 0;
unsigned long long sysVal = 0;
int childin = cmd->infd;
int childout = -1;
int childerr = -1;
- VIR_AUTOFREE(char *) binarystr = NULL;
+ g_autofree char *binarystr = NULL;
const char *binary = NULL;
int ret;
struct sigaction waxon, waxoff;
- VIR_AUTOFREE(gid_t *) groups = NULL;
+ g_autofree gid_t *groups = NULL;
int ngroups;
if (cmd->args[0][0] != '/') {
size_t inlen = 0, outlen = 0, errlen = 0;
size_t inoff = 0;
int ret = 0;
- VIR_AUTOFREE(struct pollfd *) fds = NULL;
+ g_autofree struct pollfd *fds = NULL;
if (dryRunBuffer || dryRunCallback) {
VIR_DEBUG("Dry run requested, skipping I/O processing");
virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
{
int ret = -1;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
size_t i;
bool synchronous = false;
int infd[2] = {-1, -1};
if (exitstatus && (cmd->rawStatus || WIFEXITED(status))) {
*exitstatus = cmd->rawStatus ? status : WEXITSTATUS(status);
} else if (status) {
- VIR_AUTOFREE(char *) str = virCommandToString(cmd, false);
- VIR_AUTOFREE(char *) st = virProcessTranslateStatus(status);
+ g_autofree char *str = virCommandToString(cmd, false);
+ g_autofree char *st = virProcessTranslateStatus(status);
bool haveErrMsg = cmd->errbuf && *cmd->errbuf && (*cmd->errbuf)[0];
virReportError(VIR_ERR_INTERNAL_ERROR,
return -1;
}
if (c != '1') {
- VIR_AUTOFREE(char *) msg = NULL;
+ g_autofree char *msg = NULL;
ssize_t len;
if (VIR_ALLOC_N(msg, 1024) < 0) {
VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
* combination with virCommandRunAsync():
*
* VIR_AUTOPTR(virCommand) cmd = virCommandNew*(...);
- * VIR_AUTOFREE(char *) buf = NULL;
+ * g_autofree char *buf = NULL;
*
* ...
*
{
int err;
regex_t *reg;
- VIR_AUTOFREE(regmatch_t *) vars = NULL;
+ g_autofree regmatch_t *vars = NULL;
size_t i, j, k;
int totgroups = 0, ngroup = 0, maxvars = 0;
char **groups;
- VIR_AUTOFREE(char *) outbuf = NULL;
+ g_autofree char *outbuf = NULL;
VIR_AUTOSTRINGLIST lines = NULL;
int ret = -1;
{
int save_errno = errno;
virErrorPtr err = virGetLastError();
- VIR_AUTOFREE(char *) fmtmsg = NULL;
- VIR_AUTOFREE(char *) newmsg = NULL;
+ g_autofree char *fmtmsg = NULL;
+ g_autofree char *newmsg = NULL;
va_list args;
if (!err)
*/
int virEventPollRunOnce(void)
{
- VIR_AUTOFREE(struct pollfd *) fds = NULL;
+ g_autofree struct pollfd *fds = NULL;
int ret, timeout, nfds;
virMutexLock(&eventLoop.lock);
bool
virFCIsCapableRport(const char *rport)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0)
return false;
const char *entry,
char **result)
{
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
char *p = NULL;
if (virFileReadValueString(&buf, "%s/%s/%s",
bool output = false;
int pipefd[2] = { -1, -1 };
int mode = -1;
- VIR_AUTOFREE(char *) iohelper_path = NULL;
+ g_autofree char *iohelper_path = NULL;
if (!flags) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virFileRewriteFunc rewrite,
const void *opaque)
{
- VIR_AUTOFREE(char *) newfile = NULL;
+ g_autofree char *newfile = NULL;
int fd = -1;
int ret = -1;
int lofd = -1;
int fsfd = -1;
struct loop_info64 lo;
- VIR_AUTOFREE(char *) loname = NULL;
+ g_autofree char *loname = NULL;
int ret = -1;
if ((lofd = virFileLoopDeviceOpen(&loname)) < 0)
static int
virFileNBDDeviceIsBusy(const char *dev_name)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, SYSFS_BLOCK_DIR "/%s/pid",
dev_name) < 0)
"administratively prohibited"));
return false;
} else {
- VIR_AUTOFREE(char *) errbuf = NULL;
+ g_autofree char *errbuf = NULL;
if ((errbuf = virKModLoad(NBD_DRIVER, true))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
bool readonly,
char **dev)
{
- VIR_AUTOFREE(char *) nbddev = NULL;
- VIR_AUTOFREE(char *) qemunbd = NULL;
+ g_autofree char *nbddev = NULL;
+ g_autofree char *qemunbd = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
const char *fmtstr = NULL;
return -1;
while ((direrr = virDirRead(dh, &de, dir)) > 0) {
- VIR_AUTOFREE(char *) filepath = NULL;
+ g_autofree char *filepath = NULL;
struct stat sb;
if (virAsprintf(&filepath, "%s/%s",
safezero_slow(int fd, off_t offset, off_t len)
{
int r;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
unsigned long long remain, bytes;
if (lseek(fd, offset, SEEK_SET) < 0)
const char *checkLink,
const char *checkDest)
{
- VIR_AUTOFREE(char *) candidate = NULL;
+ g_autofree char *candidate = NULL;
if (*checkLink == '/')
return virFileLinkPointsTo(checkLink, checkDest);
*/
int virFileIsMountPoint(const char *file)
{
- VIR_AUTOFREE(char *) parent = NULL;
+ g_autofree char *parent = NULL;
int ret;
struct stat sb1, sb2;
{
pid_t pid = 0;
int status, ret = 0;
- VIR_AUTOFREE(gid_t *) groups = NULL;
+ g_autofree gid_t *groups = NULL;
int ngroups;
if (uid == geteuid() &&
int recvfd_errno = 0;
int fd = -1;
int pair[2] = { -1, -1 };
- VIR_AUTOFREE(gid_t *) groups = NULL;
+ g_autofree gid_t *groups = NULL;
int ngroups;
bool created = false;
{
pid_t pid;
int status = 0, ret = 0;
- VIR_AUTOFREE(gid_t *) groups = NULL;
+ g_autofree gid_t *groups = NULL;
int ngroups;
if (!virFileRemoveNeedsSetuid(path, uid, gid)) {
struct stat st;
pid_t pid;
int status = 0, ret = 0;
- VIR_AUTOFREE(gid_t *) groups = NULL;
+ g_autofree gid_t *groups = NULL;
int ngroups;
bool created = false;
return -1;
while ((direrr = virDirRead(dir, &ent, name)) > 0) {
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, "%s/%s", name, ent->d_name) < 0)
goto cleanup;
virFileMakePathWithMode(const char *path,
mode_t mode)
{
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (VIR_STRDUP(tmp, path) < 0) {
errno = ENOMEM;
virFileMakeParentPath(const char *path)
{
char *p;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
VIR_DEBUG("path=%s", path);
* doesn't have to worry about that mess? */
int ret = -1;
int slave = -1;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
/* Unfortunately, we can't use the name argument of openpty, since
* there is no guarantee on how large the buffer has to be.
if (VIR_STRDUP(*abspath, path) < 0)
return -1;
} else {
- VIR_AUTOFREE(char *) buf = getcwd(NULL, 0);
+ g_autofree char *buf = getcwd(NULL, 0);
if (buf == NULL)
return -1;
int virFilePrintf(FILE *fp, const char *msg, ...)
{
va_list vargs;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
int ret;
va_start(vargs, msg);
virFileIsSharedFSType(const char *path,
int fstypes)
{
- VIR_AUTOFREE(char *) dirpath = NULL;
+ g_autofree char *dirpath = NULL;
char *p = NULL;
struct statfs sb;
int statfs_ret;
static int
virFileGetDefaultHugepageSize(unsigned long long *size)
{
- VIR_AUTOFREE(char *) meminfo = NULL;
+ g_autofree char *meminfo = NULL;
char *c;
char *n;
char *unit;
int
virFileComparePaths(const char *p1, const char *p2)
{
- VIR_AUTOFREE(char *) res1 = NULL;
- VIR_AUTOFREE(char *) res2 = NULL;
+ g_autofree char *res1 = NULL;
+ g_autofree char *res2 = NULL;
/* Assume p1 and p2 are symlinks, so try to resolve and canonicalize them.
* Canonicalization fails for example on file systems names like 'proc' or
int
virFileReadValueInt(int *value, const char *format, ...)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *path = NULL;
va_list ap;
va_start(ap, format);
int
virFileReadValueUint(unsigned int *value, const char *format, ...)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *path = NULL;
va_list ap;
va_start(ap, format);
int
virFileReadValueScaledInt(unsigned long long *value, const char *format, ...)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *path = NULL;
char *endp = NULL;
va_list ap;
int
virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...)
{
- VIR_AUTOFREE(char *) str = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *str = NULL;
+ g_autofree char *path = NULL;
va_list ap;
va_start(ap, format);
virFileReadValueString(char **value, const char *format, ...)
{
int ret;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
va_list ap;
va_start(ap, format);
virFileCacheGetFileName(virFileCachePtr cache,
const char *name)
{
- VIR_AUTOFREE(char *) namehash = NULL;
+ g_autofree char *namehash = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0)
const char *name,
void **data)
{
- VIR_AUTOFREE(char *) file = NULL;
+ g_autofree char *file = NULL;
int ret = -1;
void *loadData = NULL;
const char *name,
void *data)
{
- VIR_AUTOFREE(char *) file = NULL;
+ g_autofree char *file = NULL;
if (!(file = virFileCacheGetFileName(cache, name)))
return -1;
const void *iterData)
{
void *data = NULL;
- VIR_AUTOFREE(char *) name = NULL;
+ g_autofree char *name = NULL;
virObjectLock(cache);
virFirewallRulePtr rule,
const char *fmt, ...)
{
- VIR_AUTOFREE(char *) arg = NULL;
+ g_autofree char *arg = NULL;
va_list list;
VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule);
const char *bin = virFirewallLayerCommandTypeToString(rule->layer);
VIR_AUTOPTR(virCommand) cmd = NULL;
int status;
- VIR_AUTOFREE(char *) error = NULL;
+ g_autofree char *error = NULL;
if (!bin) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (ignoreErrors) {
VIR_DEBUG("Ignoring error running command");
} else {
- VIR_AUTOFREE(char *) args = virCommandToString(cmd, false);
+ g_autofree char *args = virCommandToString(cmd, false);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to apply firewall rules %s: %s"),
NULLSTR(args), NULLSTR(error));
virFirewallRulePtr rule,
bool ignoreErrors)
{
- VIR_AUTOFREE(char *) output = NULL;
- VIR_AUTOFREE(char *) str = virFirewallRuleToString(rule);
+ g_autofree char *output = NULL;
+ g_autofree char *str = virFirewallRuleToString(rule);
VIR_AUTOSTRINGLIST lines = NULL;
VIR_INFO("Applying rule '%s'", NULLSTR(str));
int ret = -1;
DBusConnection *sysbus = virDBusGetSystemBus();
DBusMessage *reply = NULL;
- VIR_AUTOFREE(char *) versionStr = NULL;
+ g_autofree char *versionStr = NULL;
if (!sysbus)
return -1;
DBusConnection *sysbus = virDBusGetSystemBus();
DBusMessage *reply = NULL;
virError error;
- VIR_AUTOFREE(char *) backendStr = NULL;
+ g_autofree char *backendStr = NULL;
int backend = -1;
if (!sysbus)
static int
virHookCheck(int no, const char *driver)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (driver == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
char **output)
{
int ret;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
const char *drvstr;
const char *opstr;
return NULL;
}
} else {
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
mode_t old_umask;
if (!(rundir = virGetUserRuntimeDirectory()))
static int
virHostdevIsVirtualFunction(virDomainHostdevDefPtr hostdev)
{
- VIR_AUTOFREE(char *) sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
if (virHostdevPCISysfsPath(hostdev, &sysfs_path) < 0)
return -1;
char **linkdev,
int *vf)
{
- VIR_AUTOFREE(char *) sysfs_path = NULL;
+ g_autofree char *sysfs_path = NULL;
if (virHostdevPCISysfsPath(hostdev, &sysfs_path) < 0)
return -1;
virHostdevSaveNetConfig(virDomainHostdevDefPtr hostdev,
const char *stateDir)
{
- VIR_AUTOFREE(char *) linkdev = NULL;
+ g_autofree char *linkdev = NULL;
int vf = -1;
if (!virHostdevIsPCINetDevice(hostdev) ||
virHostdevSetNetConfig(virDomainHostdevDefPtr hostdev,
const unsigned char *uuid)
{
- VIR_AUTOFREE(char *) linkdev = NULL;
+ g_autofree char *linkdev = NULL;
virNetDevVlanPtr vlan;
virNetDevVPortProfilePtr virtPort;
int vf = -1;
const char *stateDir,
const char *oldStateDir)
{
- VIR_AUTOFREE(char *) linkdev = NULL;
- VIR_AUTOFREE(virMacAddrPtr) MAC = NULL;
- VIR_AUTOFREE(virMacAddrPtr) adminMAC = NULL;
+ g_autofree char *linkdev = NULL;
+ g_autofree virMacAddrPtr MAC = NULL;
+ g_autofree virMacAddrPtr adminMAC = NULL;
VIR_AUTOPTR(virNetDevVlan) vlan = NULL;
virNetDevVPortProfilePtr virtPort;
int vf = -1;
mgr->inactivePCIHostdevs) < 0)
goto reattachdevs;
} else {
- VIR_AUTOFREE(char *) driverPath = NULL;
- VIR_AUTOFREE(char *) driverName = NULL;
+ g_autofree char *driverPath = NULL;
+ g_autofree char *driverName = NULL;
int stub;
/* Unmanaged devices should already have been marked as
#ifdef __linux__
{
int ret;
- VIR_AUTOFREE(char *) meminfo_path = NULL;
+ g_autofree char *meminfo_path = NULL;
FILE *meminfo;
int max_node;
static int
virHostMemSetParameterValue(virTypedParameterPtr param)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) strval = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *strval = NULL;
int rc = -1;
char *field = strchr(param->field, '_');
size_t i;
for (i = 0; i < nparams; i++) {
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
virTypedParameterPtr param = ¶ms[i];
char *field = strchr(param->field, '_');
virHostMemGetParameterValue(const char *field,
void *value)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *buf = NULL;
char *tmp = NULL;
int rc = -1;
unsigned int prefix)
{
virSocketAddr network;
- VIR_AUTOFREE(char *) netstr = NULL;
+ g_autofree char *netstr = NULL;
char *ret;
if (!(VIR_SOCKET_ADDR_IS_FAMILY(netaddr, AF_INET) ||
const char *physdev,
int action)
{
- VIR_AUTOFREE(char *) networkstr = NULL;
+ g_autofree char *networkstr = NULL;
virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ?
VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6;
{
virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ?
VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6;
- VIR_AUTOFREE(char *) networkstr = NULL;
+ g_autofree char *networkstr = NULL;
if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))
return -1;
{
virFirewallLayer layer = VIR_SOCKET_ADDR_FAMILY(netaddr) == AF_INET ?
VIR_FIREWALL_LAYER_IPV4 : VIR_FIREWALL_LAYER_IPV6;
- VIR_AUTOFREE(char *) networkstr = NULL;
+ g_autofree char *networkstr = NULL;
if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))
return -1;
const char *protocol,
int action)
{
- VIR_AUTOFREE(char *) networkstr = NULL;
- VIR_AUTOFREE(char *) addrStartStr = NULL;
- VIR_AUTOFREE(char *) addrEndStr = NULL;
- VIR_AUTOFREE(char *) portRangeStr = NULL;
- VIR_AUTOFREE(char *) natRangeStr = NULL;
+ g_autofree char *networkstr = NULL;
+ g_autofree char *addrStartStr = NULL;
+ g_autofree char *addrEndStr = NULL;
+ g_autofree char *portRangeStr = NULL;
+ g_autofree char *natRangeStr = NULL;
virFirewallRulePtr rule;
if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))
const char *destaddr,
int action)
{
- VIR_AUTOFREE(char *) networkstr = NULL;
+ g_autofree char *networkstr = NULL;
if (!(networkstr = iptablesFormatNetwork(netaddr, prefix)))
return -1;
.devpath = devpath,
};
int exitstatus = 0;
- VIR_AUTOFREE(char *) error = NULL;
+ g_autofree char *error = NULL;
VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM, "--mode",
"session", NULL);
{
int ret = IQN_ERROR;
char *line = NULL;
- VIR_AUTOFREE(char *) outbuf = NULL;
- VIR_AUTOFREE(char *) iface = NULL;
- VIR_AUTOFREE(char *) iqn = NULL;
+ g_autofree char *outbuf = NULL;
+ g_autofree char *iface = NULL;
+ g_autofree char *iqn = NULL;
VIR_AUTOPTR(virCommand) cmd = virCommandNewArgList(ISCSIADM,
"--mode", "iface", NULL);
char **ifacename)
{
int exitstatus = -1;
- VIR_AUTOFREE(char *) iface_name = NULL;
- VIR_AUTOFREE(char *) temp_ifacename = NULL;
+ g_autofree char *iface_name = NULL;
+ g_autofree char *temp_ifacename = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
if (virAsprintf(&temp_ifacename,
NULL
};
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) ifacename = NULL;
+ g_autofree char *ifacename = NULL;
cmd = virCommandNewArgs(baseargv);
virCommandAddArgSet(cmd, extraargv);
void *data)
{
struct virISCSITargetList *list = data;
- VIR_AUTOFREE(char *) target = NULL;
+ g_autofree char *target = NULL;
if (VIR_STRDUP(target, groups[1]) < 0)
return -1;
size_t *ntargets,
char ***targets)
{
- VIR_AUTOFREE(char *) ifacename = NULL;
+ g_autofree char *ifacename = NULL;
if (ntargets)
*ntargets = 0;
virJSONValuePtr
virJSONValueNewNumberInt(int data)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (virAsprintf(&str, "%i", data) < 0)
return NULL;
return virJSONValueNewNumber(str);
virJSONValuePtr
virJSONValueNewNumberUint(unsigned int data)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (virAsprintf(&str, "%u", data) < 0)
return NULL;
return virJSONValueNewNumber(str);
virJSONValuePtr
virJSONValueNewNumberLong(long long data)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (virAsprintf(&str, "%lld", data) < 0)
return NULL;
return virJSONValueNewNumber(str);
virJSONValuePtr
virJSONValueNewNumberUlong(unsigned long long data)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (virAsprintf(&str, "%llu", data) < 0)
return NULL;
return virJSONValueNewNumber(str);
virJSONValuePtr
virJSONValueNewNumberDouble(double data)
{
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (virDoubleToStr(&str, data) < 0)
return NULL;
return virJSONValueNewNumber(str);
{
virJSONValuePtr elem;
size_t i;
- VIR_AUTOFREE(unsigned long long *) elems = NULL;
+ g_autofree unsigned long long *elems = NULL;
unsigned long long maxelem = 0;
*bitmap = NULL;
virKModIsBlacklisted(const char *module)
{
size_t i;
- VIR_AUTOFREE(char *) drvblklst = NULL;
- VIR_AUTOFREE(char *) outbuf = NULL;
+ g_autofree char *drvblklst = NULL;
+ g_autofree char *outbuf = NULL;
if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0)
return false;
const char *ip_to_delete,
char **server_duid)
{
- VIR_AUTOFREE(char *) lease_entries = NULL;
+ g_autofree char *lease_entries = NULL;
VIR_AUTOPTR(virJSONValue) leases_array = NULL;
long long expirytime;
int custom_lease_file_len = 0;
VIR_AUTOPTR(virJSONValue) lease_new = NULL;
const char *exptime_tmp = getenv("DNSMASQ_LEASE_EXPIRES");
long long expirytime = 0;
- VIR_AUTOFREE(char *) exptime = NULL;
+ g_autofree char *exptime = NULL;
/* In case hostname is still unknown, use the last known one */
if (!hostname)
virMediatedDeviceGetSysfsDeviceAPI(virMediatedDevicePtr dev,
char **device_api)
{
- VIR_AUTOFREE(char *) buf = NULL;
- VIR_AUTOFREE(char *) file = NULL;
+ g_autofree char *buf = NULL;
+ g_autofree char *file = NULL;
char *tmp = NULL;
if (virAsprintf(&file, "%s/mdev_type/device_api", dev->path) < 0)
virMediatedDeviceCheckModel(virMediatedDevicePtr dev,
virMediatedDeviceModelType model)
{
- VIR_AUTOFREE(char *) dev_api = NULL;
+ g_autofree char *dev_api = NULL;
int actual_model;
if (virMediatedDeviceGetSysfsDeviceAPI(dev, &dev_api) < 0)
{
virMediatedDevicePtr ret = NULL;
VIR_AUTOPTR(virMediatedDevice) dev = NULL;
- VIR_AUTOFREE(char *) sysfspath = NULL;
+ g_autofree char *sysfspath = NULL;
if (!(sysfspath = virMediatedDeviceGetSysfsPath(uuidstr)))
return NULL;
char *
virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr)
{
- VIR_AUTOFREE(char *) result_path = NULL;
- VIR_AUTOFREE(char *) iommu_path = NULL;
- VIR_AUTOFREE(char *) dev_path = virMediatedDeviceGetSysfsPath(uuidstr);
+ g_autofree char *result_path = NULL;
+ g_autofree char *iommu_path = NULL;
+ g_autofree char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr);
char *vfio_path = NULL;
if (!dev_path)
int
virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr)
{
- VIR_AUTOFREE(char *) vfio_path = NULL;
+ g_autofree char *vfio_path = NULL;
char *group_num_str = NULL;
unsigned int group_num = -1;
int fd, /* control socket */
struct ifreq *ifr) /* pre-filled bridge name */
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, SYSFS_NET_DIR "%s/bridge/%s", brname, paramname) < 0)
return -1;
unsigned long *value) /* current value */
{
struct ifreq ifr;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_AUTOCLOSE fd = -1;
if (virAsprintf(&path, SYSFS_NET_DIR "%s/bridge/%s", brname, paramname) < 0)
return -1;
if (virFileExists(path)) {
- VIR_AUTOFREE(char *) valuestr = NULL;
+ g_autofree char *valuestr = NULL;
if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long),
&valuestr) < 0)
{
char valuestr[INT_BUFSIZE_BOUND(value)];
int ret = -1;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
snprintf(valuestr, sizeof(valuestr), "%lu", value);
const char *paramname,
unsigned long *value)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) valuestr = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *valuestr = NULL;
if (virAsprintf(&path, SYSFS_NET_DIR "%s/brif/%s/%s",
brname, ifname, paramname) < 0)
unsigned int recvbuflen;
struct ndmsg ndm = { .ndm_family = PF_BRIDGE, .ndm_state = NUD_NOARP };
VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
if (virNetDevGetIndex(ifname, &ndm.ndm_ifindex) < 0)
return -1;
unsigned int recvbuflen;
VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
VIR_AUTOPTR(virSocketAddr) broadcast = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
- VIR_AUTOFREE(char *) ipStr = NULL;
- VIR_AUTOFREE(char *) peerStr = NULL;
- VIR_AUTOFREE(char *) bcastStr = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
+ g_autofree char *ipStr = NULL;
+ g_autofree char *peerStr = NULL;
+ g_autofree char *bcastStr = NULL;
ipStr = virSocketAddrFormat(addr);
if (peer && VIR_SOCKET_ADDR_VALID(peer))
{
unsigned int recvbuflen;
VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_DELADDR, ifname,
addr, prefix,
virSocketAddr defaultAddr;
virSocketAddrPtr actualAddr;
VIR_AUTOPTR(virNetlinkMsg) nlmsg = NULL;
- VIR_AUTOFREE(char *) toStr = NULL;
- VIR_AUTOFREE(char *) viaStr = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree char *toStr = NULL;
+ g_autofree char *viaStr = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
actualAddr = addr;
/* Periodically query netlink until DAD finishes on all known addresses. */
while (dad && time(NULL) < max_time) {
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
if (virNetlinkCommand(nlmsg, &resp, &recvbuflen, 0, 0,
NETLINK_ROUTE, 0) < 0)
static int
virNetDevIPGetAcceptRA(const char *ifname)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *buf = NULL;
char *suffix;
int accept_ra = -1;
struct rtattr *rta_attr;
int accept_ra = -1;
int ifindex = -1;
- VIR_AUTOFREE(char *) ifname = NULL;
+ g_autofree char *ifname = NULL;
/* Ignore messages other than route ones */
if (resp->nlmsg_type != RTM_NEWROUTE)
{
virSocketAddr broadcast;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) addrstr = NULL;
- VIR_AUTOFREE(char *) bcaststr = NULL;
- VIR_AUTOFREE(char *) peerstr = NULL;
+ g_autofree char *addrstr = NULL;
+ g_autofree char *bcaststr = NULL;
+ g_autofree char *peerstr = NULL;
if (!(addrstr = virSocketAddrFormat(addr)))
return -1;
unsigned int prefix)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) addrstr = NULL;
+ g_autofree char *addrstr = NULL;
if (!(addrstr = virSocketAddrFormat(addr)))
return -1;
unsigned int metric)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) addrstr = NULL;
- VIR_AUTOFREE(char *) gatewaystr = NULL;
+ g_autofree char *addrstr = NULL;
+ g_autofree char *gatewaystr = NULL;
if (!(addrstr = virSocketAddrFormat(addr)))
return -1;
{
size_t i;
int prefix;
- VIR_AUTOFREE(char *) ipStr = NULL;
+ g_autofree char *ipStr = NULL;
/* add all IP addresses */
for (i = 0; i < ipInfo->nips; i++) {
virNetDevMacVLanIsMacvtap(const char *ifname)
{
int ifindex;
- VIR_AUTOFREE(char *) tapname = NULL;
+ g_autofree char *tapname = NULL;
if (virNetDevGetIndex(ifname, &ifindex) < 0)
return false;
int ret = -1;
int ifindex;
size_t i = 0;
- VIR_AUTOFREE(char *) tapname = NULL;
+ g_autofree char *tapname = NULL;
if (virNetDevGetIndex(ifname, &ifindex) < 0)
return -1;
char ifuuidstr[VIR_UUID_STRING_BUFLEN];
char vmuuidstr[VIR_UUID_STRING_BUFLEN];
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) attachedmac_ex_id = NULL;
- VIR_AUTOFREE(char *) ifaceid_ex_id = NULL;
- VIR_AUTOFREE(char *) profile_ex_id = NULL;
- VIR_AUTOFREE(char *) vmid_ex_id = NULL;
+ g_autofree char *attachedmac_ex_id = NULL;
+ g_autofree char *ifaceid_ex_id = NULL;
+ g_autofree char *profile_ex_id = NULL;
+ g_autofree char *vmid_ex_id = NULL;
virMacAddrFormat(macaddr, macaddrstr);
virUUIDFormat(ovsport->interfaceID, ifuuidstr);
virDomainInterfaceStatsPtr stats)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
cmd = virCommandNew(OVSVSCTL);
virNetDevOpenvswitchAddTimeout(cmd);
if (strstr(*ifname, "%d") != NULL) {
size_t i;
for (i = 0; i <= IF_MAXUNIT; i++) {
- VIR_AUTOFREE(char *) newname = NULL;
+ g_autofree char *newname = NULL;
if (virAsprintf(&newname, *ifname, i) < 0)
goto cleanup;
}
if (tapfd) {
- VIR_AUTOFREE(char *) dev_path = NULL;
+ g_autofree char *dev_path = NULL;
if (virAsprintf(&dev_path, "/dev/%s", ifr.ifr_name) < 0)
goto cleanup;
unsigned int *actualMTU)
{
bool useOVS = false;
- VIR_AUTOFREE(char *) master = NULL;
+ g_autofree char *master = NULL;
if (virNetDevGetMaster(tapname, &master) < 0)
return -1;
static int virNetDevVethExists(int devNum)
{
int ret;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, SYSFS_NET_DIR "vnet%d/", devNum) < 0)
return -1;
#define MAX_VETH_RETRIES 10
for (i = 0; i < MAX_VETH_RETRIES; i++) {
- VIR_AUTOFREE(char *) veth1auto = NULL;
- VIR_AUTOFREE(char *) veth2auto = NULL;
+ g_autofree char *veth1auto = NULL;
+ g_autofree char *veth2auto = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
int status;
.nl_groups = 0,
};
struct pollfd fds[1];
- VIR_AUTOFREE(struct nlmsghdr *) temp_resp = NULL;
+ g_autofree struct nlmsghdr *temp_resp = NULL;
VIR_AUTOPTR(virNetlinkHandle) nlhandle = NULL;
int len = 0;
return -1;
while (!end) {
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
len = nl_recv(nlhandle, &nladdr, (unsigned char **)&resp, NULL);
VIR_WARNINGS_NO_CAST_ALIGN
};
unsigned int recvbuflen;
VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
if (ifname && ifindex <= 0 && virNetDevGetIndex(ifname, &ifindex) < 0)
return -1;
unsigned int buflen;
struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
*error = 0;
struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
unsigned int recvbuflen;
VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
nl_msg = nlmsg_alloc_simple(RTM_DELLINK,
NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
};
unsigned int recvbuflen;
VIR_AUTOPTR(virNetlinkMsg) nl_msg = NULL;
- VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
+ g_autofree struct nlmsghdr *resp = NULL;
nl_msg = nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST);
if (!nl_msg) {
size_t i;
int length;
bool handled = false;
- VIR_AUTOFREE(struct nlmsghdr *) msg = NULL;
+ g_autofree struct nlmsghdr *msg = NULL;
length = nl_recv(srv->netlinknh, &peer,
(unsigned char **)&msg, &creds);
virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) binary = NULL;
+ g_autofree char *binary = NULL;
int status;
*supported = false;
int max_n_cpus = virNumaGetMaxCPUs();
int mask_n_bytes = max_n_cpus / 8;
size_t i;
- VIR_AUTOFREE(unsigned long *) mask = NULL;
- VIR_AUTOFREE(unsigned long *) allonesmask = NULL;
+ g_autofree unsigned long *mask = NULL;
+ g_autofree unsigned long *allonesmask = NULL;
VIR_AUTOPTR(virBitmap) cpumap = NULL;
*cpus = NULL;
unsigned long long *page_free)
{
char *end;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *buf = NULL;
if (page_avail) {
if (virNumaGetHugePageInfoPath(&path, node,
bool exchange;
long system_page_size;
unsigned long long huge_page_sum = 0;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(unsigned int *) tmp_size = NULL;
- VIR_AUTOFREE(unsigned long long *) tmp_avail = NULL;
- VIR_AUTOFREE(unsigned long long *) tmp_free = NULL;
+ g_autofree char *path = NULL;
+ g_autofree unsigned int *tmp_size = NULL;
+ g_autofree unsigned long long *tmp_avail = NULL;
+ g_autofree unsigned long long *tmp_free = NULL;
/* sysconf() returns page size in bytes,
* but we are storing the page size in kibibytes. */
{
char *end;
unsigned long long nr_count;
- VIR_AUTOFREE(char *) nr_path = NULL;
- VIR_AUTOFREE(char *) nr_buf = NULL;
+ g_autofree char *nr_path = NULL;
+ g_autofree char *nr_buf = NULL;
if (page_size == virGetSystemPageSizeKB()) {
/* Special case as kernel handles system pages
virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name)
{
int ret = -1;
- VIR_AUTOFREE(char *) drvlink = NULL;
+ g_autofree char *drvlink = NULL;
*path = *name = NULL;
/* drvlink = "/sys/bus/pci/dddd:bb:ss.ff/driver" */
static int
virPCIDeviceReadClass(virPCIDevicePtr dev, uint16_t *device_class)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) id_str = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *id_str = NULL;
unsigned int value;
if (!(path = virPCIFile(dev->name, "class")))
{
uint32_t caps;
uint8_t pos;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
int found;
/* The PCIe Function Level Reset capability allows
virPCIDeviceList *activeDevs,
virPCIDeviceList *inactiveDevs)
{
- VIR_AUTOFREE(char *) drvPath = NULL;
- VIR_AUTOFREE(char *) drvName = NULL;
+ g_autofree char *drvPath = NULL;
+ g_autofree char *drvName = NULL;
int ret = -1;
int fd = -1;
int hdrType = -1;
virPCIProbeStubDriver(virPCIStubDriver driver)
{
const char *drvname = NULL;
- VIR_AUTOFREE(char *) drvpath = NULL;
+ g_autofree char *drvpath = NULL;
bool probed = false;
if (driver == VIR_PCI_STUB_DRIVER_NONE ||
return 0;
if (!probed) {
- VIR_AUTOFREE(char *) errbuf = NULL;
+ g_autofree char *errbuf = NULL;
probed = true;
if ((errbuf = virKModLoad(drvname, true))) {
VIR_WARN("failed to load driver %s: %s", drvname, errbuf);
int
virPCIDeviceUnbind(virPCIDevicePtr dev)
{
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) drvpath = NULL;
- VIR_AUTOFREE(char *) driver = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *drvpath = NULL;
+ g_autofree char *driver = NULL;
if (virPCIDeviceGetDriverPathAndName(dev, &drvpath, &driver) < 0)
return -1;
virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev,
const char *driverName)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (!(path = virPCIFile(dev->name, "driver_override")))
return -1;
virPCIDeviceBindToStub(virPCIDevicePtr dev)
{
const char *stubDriverName;
- VIR_AUTOFREE(char *) stubDriverPath = NULL;
- VIR_AUTOFREE(char *) driverLink = NULL;
+ g_autofree char *stubDriverPath = NULL;
+ g_autofree char *driverLink = NULL;
/* Check the device is configured to use one of the known stub drivers */
if (dev->stubDriver == VIR_PCI_STUB_DRIVER_NONE) {
static char *
virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
char *id_str;
if (!(path = virPCIFile(dev->name, id_name)))
unsigned int function)
{
VIR_AUTOPTR(virPCIDevice) dev = NULL;
- VIR_AUTOFREE(char *) vendor = NULL;
- VIR_AUTOFREE(char *) product = NULL;
+ g_autofree char *vendor = NULL;
+ g_autofree char *product = NULL;
if (VIR_ALLOC(dev) < 0)
return NULL;
virPCIDeviceFileActor actor,
void *opaque)
{
- VIR_AUTOFREE(char *) pcidir = NULL;
+ g_autofree char *pcidir = NULL;
DIR *dir = NULL;
int ret = -1;
struct dirent *ent;
goto cleanup;
while ((direrr = virDirRead(dir, &ent, pcidir)) > 0) {
- VIR_AUTOFREE(char *) file = NULL;
+ g_autofree char *file = NULL;
/* Device assignment requires:
* $PCIDIR/config, $PCIDIR/resource, $PCIDIR/resourceNNN,
* $PCIDIR/rom, $PCIDIR/reset, $PCIDIR/vendor, $PCIDIR/device
virPCIDeviceAddressActor actor,
void *opaque)
{
- VIR_AUTOFREE(char *) groupPath = NULL;
+ g_autofree char *groupPath = NULL;
DIR *groupDir = NULL;
int ret = -1;
struct dirent *ent;
int
virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddressPtr addr)
{
- VIR_AUTOFREE(char *) devName = NULL;
- VIR_AUTOFREE(char *) devPath = NULL;
- VIR_AUTOFREE(char *) groupPath = NULL;
+ g_autofree char *devName = NULL;
+ g_autofree char *devPath = NULL;
+ g_autofree char *groupPath = NULL;
const char *groupNumStr;
unsigned int groupNum;
char *
virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev)
{
- VIR_AUTOFREE(char *) devPath = NULL;
- VIR_AUTOFREE(char *) groupPath = NULL;
+ g_autofree char *devPath = NULL;
+ g_autofree char *groupPath = NULL;
char *groupDev = NULL;
if (!(devPath = virPCIFile(dev->name, "iommu_group")))
{
virPCIDeviceAddressPtr bdf = NULL;
char *config_address = NULL;
- VIR_AUTOFREE(char *) device_path = NULL;
+ g_autofree char *device_path = NULL;
if (!virFileExists(device_link)) {
VIR_DEBUG("'%s' does not exist", device_link);
virPCIGetPhysicalFunction(const char *vf_sysfs_path,
virPCIDeviceAddressPtr *pf)
{
- VIR_AUTOFREE(char *) device_link = NULL;
+ g_autofree char *device_link = NULL;
*pf = NULL;
{
int ret = -1;
size_t i;
- VIR_AUTOFREE(char *) totalvfs_file = NULL;
- VIR_AUTOFREE(char *) totalvfs_str = NULL;
+ g_autofree char *totalvfs_file = NULL;
+ g_autofree char *totalvfs_str = NULL;
virPCIDeviceAddressPtr config_addr = NULL;
*virtual_functions = NULL;
}
do {
- VIR_AUTOFREE(char *) device_link = NULL;
+ g_autofree char *device_link = NULL;
/* look for virtfn%d links until one isn't found */
if (virAsprintf(&device_link, "%s/virtfn%zu", sysfs_path, *num_virtual_functions) < 0)
goto error;
int
virPCIIsVirtualFunction(const char *vf_sysfs_device_link)
{
- VIR_AUTOFREE(char *) vf_sysfs_physfn_link = NULL;
+ g_autofree char *vf_sysfs_physfn_link = NULL;
if (virAsprintf(&vf_sysfs_physfn_link, "%s/physfn",
vf_sysfs_device_link) < 0)
char *physPortID,
char **netname)
{
- VIR_AUTOFREE(char *) pcidev_sysfs_net_path = NULL;
- VIR_AUTOFREE(char *) firstEntryName = NULL;
- VIR_AUTOFREE(char *) thisPhysPortID = NULL;
+ g_autofree char *pcidev_sysfs_net_path = NULL;
+ g_autofree char *firstEntryName = NULL;
+ g_autofree char *thisPhysPortID = NULL;
int ret = -1;
DIR *dir = NULL;
struct dirent *entry = NULL;
int *vf_index)
{
virPCIDeviceAddressPtr pf_config_address = NULL;
- VIR_AUTOFREE(char *) pf_sysfs_device_path = NULL;
- VIR_AUTOFREE(char *) vfname = NULL;
- VIR_AUTOFREE(char *) vfPhysPortID = NULL;
+ g_autofree char *pf_sysfs_device_path = NULL;
+ g_autofree char *vfname = NULL;
+ g_autofree char *vfPhysPortID = NULL;
int ret = -1;
if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0)
int dirret = -1;
DIR *dir = NULL;
struct dirent *entry;
- VIR_AUTOFREE(char *) types_path = NULL;
+ g_autofree char *types_path = NULL;
VIR_AUTOPTR(virMediatedDeviceType) mdev_type = NULL;
virMediatedDeviceTypePtr *mdev_types = NULL;
size_t ntypes = 0;
}
while ((dirret = virDirRead(dir, &entry, types_path)) > 0) {
- VIR_AUTOFREE(char *) tmppath = NULL;
+ g_autofree char *tmppath = NULL;
/* append the type id to the path and read the attributes from there */
if (virAsprintf(&tmppath, "%s/%s", types_path, entry->d_name) < 0)
goto cleanup;
{
char *tmp = NULL;
unsigned int attr_type = 0;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
if (virFileReadAllQuiet("/sys/devices/intel_cqm/type", 10, &buf) < 0)
return -1;
}
if (type == VIR_PERF_EVENT_CMT) {
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
if (virFileReadAll("/sys/devices/intel_cqm/events/llc_occupancy.scale",
10, &buf) < 0)
const char *name,
pid_t pid)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
if (name == NULL || dir == NULL)
return -EINVAL;
const char *name,
pid_t *pid)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
*pid = 0;
const char deletedText[] = " (deleted)";
size_t deletedTextLen = strlen(deletedText);
pid_t retPid;
- VIR_AUTOFREE(char *) procPath = NULL;
- VIR_AUTOFREE(char *) procLink = NULL;
- VIR_AUTOFREE(char *) resolvedBinPath = NULL;
- VIR_AUTOFREE(char *) resolvedProcLink = NULL;
+ g_autofree char *procPath = NULL;
+ g_autofree char *procLink = NULL;
+ g_autofree char *resolvedBinPath = NULL;
+ g_autofree char *resolvedProcLink = NULL;
/* only set this at the very end on success */
*pid = -1;
pid_t *pid,
const char *binpath)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
if (name == NULL || dir == NULL)
return -EINVAL;
int virPidFileDelete(const char *dir,
const char *name)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
if (name == NULL || dir == NULL)
return -EINVAL;
bool waitForLock,
pid_t pid)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
if (name == NULL || dir == NULL)
return -EINVAL;
const char *name,
int fd)
{
- VIR_AUTOFREE(char *) pidfile = NULL;
+ g_autofree char *pidfile = NULL;
if (name == NULL || dir == NULL)
return -EINVAL;
const char *progname,
char **pidfile)
{
- VIR_AUTOFREE(char *) rundir = NULL;
+ g_autofree char *rundir = NULL;
if (privileged) {
/*
int saved_errno;
int ret;
int status;
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (pid <= 0)
return;
{
int ret;
int status;
- VIR_AUTOFREE(char *) st = NULL;
+ g_autofree char *st = NULL;
if (pid <= 0) {
if (pid != -1)
DIR *dir = NULL;
int value;
struct dirent *ent;
- VIR_AUTOFREE(char *) taskPath = NULL;
+ g_autofree char *taskPath = NULL;
*npids = 0;
*pids = NULL;
for (i = 0; i < G_N_ELEMENTS(ns); i++) {
int fd;
- VIR_AUTOFREE(char *) nsfile = NULL;
+ g_autofree char *nsfile = NULL;
if (virAsprintf(&nsfile, "/proc/%llu/ns/%s",
(long long) pid,
{
char *tmp;
int len;
- VIR_AUTOFREE(char *) filename = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *filename = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOSTRINGLIST tokens = NULL;
if (virAsprintf(&filename, "/proc/%llu/stat", (long long) pid) < 0)
virProcessNamespaceHelperData *data = opaque;
int fd = -1;
int ret = -1;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
if (virAsprintf(&path, "/proc/%lld/ns/mnt", (long long) data->pid) < 0)
goto cleanup;
_exit(ret < 0 ? EXIT_CANCELED : ret);
} else {
int status;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_FORCE_CLOSE(errfd[1]);
ignore_value(virFileReadHeaderFD(errfd[0], 1024, &buf));
int cpid;
char *childStack;
int stacksize = getpagesize() * 4;
- VIR_AUTOFREE(char *)stack = NULL;
+ g_autofree char *stack = NULL;
if (ns & VIR_PROCESS_NAMESPACE_MNT)
flags |= CLONE_NEWNS;
for (i = 0; i < virJSONValueArraySize(array); i++) {
member = virJSONValueArrayGet((virJSONValuePtr) array, i);
- VIR_AUTOFREE(char *) prefix = NULL;
+ g_autofree char *prefix = NULL;
if (virAsprintf(&prefix, "%s.%zu", key, i) < 0)
return 0;
struct virQEMUCommandLineJSONIteratorData *data = opaque;
if (data->prefix) {
- VIR_AUTOFREE(char *) tmpkey = NULL;
+ g_autofree char *tmpkey = NULL;
if (virAsprintf(&tmpkey, "%s.%s", data->prefix, key) < 0)
return -1;
virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor,
const char *machinename)
{
- VIR_AUTOFREE(char *) parentpath = NULL;
+ g_autofree char *parentpath = NULL;
if (!monitor) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
{
DIR *dir = NULL;
struct dirent *entry;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
char *sg = NULL;
unsigned int adapter_id;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
{
DIR *dir = NULL;
struct dirent *entry;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
char *name = NULL;
unsigned int adapter_id;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
{
VIR_AUTOPTR(virSCSIDevice) dev = NULL;
virSCSIDevicePtr ret = NULL;
- VIR_AUTOFREE(char *) sg = NULL;
- VIR_AUTOFREE(char *) vendor_path = NULL;
- VIR_AUTOFREE(char *) model_path = NULL;
- VIR_AUTOFREE(char *) vendor = NULL;
- VIR_AUTOFREE(char *) model = NULL;
+ g_autofree char *sg = NULL;
+ g_autofree char *vendor_path = NULL;
+ g_autofree char *model_path = NULL;
+ g_autofree char *vendor = NULL;
+ g_autofree char *model = NULL;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
if (VIR_ALLOC(dev) < 0)
}
if (withService) {
- VIR_AUTOFREE(char *) ipv6_host = NULL;
+ g_autofree char *ipv6_host = NULL;
/* sasl_new_client demands the socket address to be in an odd format:
* a.b.c.d;port or e:f:g:h:i:j:k:l;port, so use square brackets for
* IPv6 only if no separator is passed to the function
int ret = 0;
size_t i;
virSocketAddr netmask;
- VIR_AUTOFREE(char *) startStr = NULL;
- VIR_AUTOFREE(char *) endStr = NULL;
- VIR_AUTOFREE(char *) netStr = NULL;
+ g_autofree char *startStr = NULL;
+ g_autofree char *endStr = NULL;
+ g_autofree char *netStr = NULL;
if (start == NULL || end == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
switch (magic) {
case QCOW2_HDR_EXTENSION_BACKING_FORMAT: {
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!backingFormat)
break;
char *start, *end;
size_t len;
int ret = BACKING_STORE_ERROR;
- VIR_AUTOFREE(char *) desc = NULL;
+ g_autofree char *desc = NULL;
if (VIR_ALLOC_N(desc, VIR_STORAGE_MAX_HEADER) < 0)
goto cleanup;
struct stat sb;
ssize_t len = VIR_STORAGE_MAX_HEADER;
VIR_AUTOCLOSE fd = -1;
- VIR_AUTOFREE(char *) header = NULL;
+ g_autofree char *header = NULL;
if ((fd = virFileOpenAs(path, O_RDONLY, 0, uid, gid, 0)) < 0) {
virReportSystemError(-fd, _("Failed to open file '%s'"), path);
ssize_t len = VIR_STORAGE_MAX_HEADER;
struct stat sb;
int dummy;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL;
if (!backingFormat)
int status;
const char *serial;
const char *port;
- VIR_AUTOFREE(char *) outbuf = NULL;
+ g_autofree char *outbuf = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
cmd = virCommandNewArgList("/lib/udev/scsi_id",
unsigned int *chainIndex)
{
unsigned int idx = 0;
- VIR_AUTOFREE(char *) target = NULL;
+ g_autofree char *target = NULL;
*chainIndex = 0;
virStorageAuthDefPtr ret = NULL;
xmlNodePtr secretnode = NULL;
VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
- VIR_AUTOFREE(char *) authtype = NULL;
+ g_autofree char *authtype = NULL;
ctxt->node = node;
{
virStoragePRDefPtr prd;
virStoragePRDefPtr ret = NULL;
- VIR_AUTOFREE(char *) managed = NULL;
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) mode = NULL;
+ g_autofree char *managed = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *mode = NULL;
if (VIR_ALLOC(prd) < 0)
return NULL;
const char *rel)
{
virStorageSourcePtr ret = NULL;
- VIR_AUTOFREE(char *) dirname = NULL;
+ g_autofree char *dirname = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;
if (!(def = virStorageSourceNew()))
virStorageSourcePtr src)
{
char *p, *e, *next;
- VIR_AUTOFREE(char *) options = NULL;
+ g_autofree char *options = NULL;
VIR_AUTOPTR(virStorageAuthDef) authdef = NULL;
/* optionally skip the "rbd:" prefix if provided */
const char *path)
{
const char *p;
- VIR_AUTOFREE(char *) protocol = NULL;
+ g_autofree char *protocol = NULL;
if (!(p = strchr(path, ':'))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
virJSONValuePtr file;
const char *drvname;
size_t i;
- VIR_AUTOFREE(char *) str = NULL;
+ g_autofree char *str = NULL;
if (!(deflattened = virJSONValueObjectDeflatten(json)))
return -1;
size_t j = 0;
int rc;
char *ret = NULL;
- VIR_AUTOFREE(char *) linkpath = NULL;
- VIR_AUTOFREE(char *) currentpath = NULL;
+ g_autofree char *linkpath = NULL;
+ g_autofree char *currentpath = NULL;
if (path[0] == '/') {
beginSlash = true;
char **relpath)
{
virStorageSourcePtr next;
- VIR_AUTOFREE(char *) tmp = NULL;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *tmp = NULL;
+ g_autofree char *path = NULL;
*relpath = NULL;
ssize_t headerLen;
int backingFormat;
int rv;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) backingStore = NULL;
VIR_DEBUG("path=%s format=%d uid=%u gid=%u",
{
ssize_t headerLen;
int rv;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) tmp = NULL;
*backing = NULL;
{
int exitstatus;
virBitmapPtr bitmap;
- VIR_AUTOFREE(char *) outbuf = NULL;
+ g_autofree char *outbuf = NULL;
VIR_AUTOPTR(virJSONValue) json = NULL;
virJSONValuePtr featureList;
virJSONValuePtr item;
virMutexLock(&swtpm_tools_lock);
for (i = 0; i < G_N_ELEMENTS(prgs); i++) {
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
bool findit = *prgs[i].path == NULL;
struct stat statbuf;
char *tmp;
int base, unsigned int *value)
{
int tmp;
- VIR_AUTOFREE(char *) buf = NULL;
- VIR_AUTOFREE(char *) filename = NULL;
+ g_autofree char *buf = NULL;
+ g_autofree char *filename = NULL;
char *ignore = NULL;
tmp = virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_name);
void virWaitForDevices(void)
{
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) udev = NULL;
+ g_autofree char *udev = NULL;
int exitstatus;
if (!(udev = virFindFileInPath(UDEVADM)))
cpuTestCompareSignature(const struct data *data,
virCPUDataPtr hostData)
{
- VIR_AUTOFREE(char *) result = NULL;
- VIR_AUTOFREE(char *) sigStr = NULL;
+ g_autofree char *result = NULL;
+ g_autofree char *sigStr = NULL;
unsigned long signature;
unsigned int family;
unsigned int model;
mymain(void)
{
int ret = 0;
- VIR_AUTOFREE(char *)basefile = NULL;
- VIR_AUTOFREE(char *)baseargs = NULL;
+ g_autofree char *basefile = NULL;
+ g_autofree char *baseargs = NULL;
# define DO_TEST(name) \
do { \
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
VIR_AUTOPTR(virJSONValue) backendprops = NULL;
VIR_AUTOPTR(virJSONValue) wrapper = NULL;
- VIR_AUTOFREE(char *) propsstr = NULL;
- VIR_AUTOFREE(char *) protocolwrapper = NULL;
- VIR_AUTOFREE(char *) actualxml = NULL;
+ g_autofree char *propsstr = NULL;
+ g_autofree char *protocolwrapper = NULL;
+ g_autofree char *actualxml = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) xmlsrc = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) jsonsrc = NULL;
VIR_AUTOPTR(xmlDoc) doc = NULL;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
xmlNodePtr node;
- VIR_AUTOFREE(char *) xmlpath = NULL;
+ g_autofree char *xmlpath = NULL;
virStorageSourcePtr ret = NULL;
if (virAsprintf(&xmlpath, "%s%s.xml",
VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) actualbuf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) jsonprotocol = NULL;
- VIR_AUTOFREE(char *) jsonformat = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
- VIR_AUTOFREE(char *) jsonpath = NULL;
+ g_autofree char *jsonprotocol = NULL;
+ g_autofree char *jsonformat = NULL;
+ g_autofree char *actual = NULL;
+ g_autofree char *jsonpath = NULL;
if (!(src = testQemuImageCreateLoadDiskXML(data->name, data->driver->xmlopt)))
return -1;
if (testQEMUSchemaValidate(formatprops, data->schemaroot, data->schema,
&debug) < 0) {
- VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug);
+ g_autofree char *debugmsg = virBufferContentAndReset(&debug);
VIR_TEST_VERBOSE("blockdev-create format json does not conform to QAPI schema");
VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
jsonformat, NULLSTR(debugmsg));
if (testQEMUSchemaValidate(protocolprops, data->schemaroot, data->schema,
&debug) < 0) {
- VIR_AUTOFREE(char *) debugmsg = virBufferContentAndReset(&debug);
+ g_autofree char *debugmsg = virBufferContentAndReset(&debug);
VIR_TEST_VERBOSE("blockdev-create protocol json does not conform to QAPI schema");
VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output:\n %s",
jsonprotocol, NULLSTR(debugmsg));
{
struct testQemuDiskXMLToJSONData *data = (void *) opaque;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) jsonpath = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *jsonpath = NULL;
+ g_autofree char *actual = NULL;
size_t i;
if (data->fail)
return -1;
for (i = 0; i < data->npropssrc; i++) {
- VIR_AUTOFREE(char *) jsonstr = NULL;
+ g_autofree char *jsonstr = NULL;
if (!(jsonstr = virJSONValueToString(data->propssrc[i], true)))
return -1;
void *opaque)
{
testQemuDataPtr data = (testQemuDataPtr) opaque;
- VIR_AUTOFREE(char *) title = NULL;
- VIR_AUTOFREE(char *) copyTitle = NULL;
+ g_autofree char *title = NULL;
+ g_autofree char *copyTitle = NULL;
if (virAsprintf(&title, "%s (%s)", base, archName) < 0 ||
virAsprintf(©Title, "copy %s (%s)", base, archName) < 0) {
virQEMUCapsPtr qemuCaps = NULL;
virCapsPtr caps = NULL;
virArch arch = virArchFromString(data->archName);
- VIR_AUTOFREE(char *) binary = NULL;
+ g_autofree char *binary = NULL;
if (virAsprintf(&binary, "/usr/bin/qemu-system-%s", data->archName) < 0)
goto error;
void *opaque)
{
testQemuDataPtr data = (testQemuDataPtr) opaque;
- VIR_AUTOFREE(char *) title = NULL;
+ g_autofree char *title = NULL;
if (virAsprintf(&title, "%s (%s)", base, archName) < 0)
return -1;
{
unsigned int parseflags = 0;
unsigned int formatflags = VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE;
- VIR_AUTOFREE(char *) inXmlData = NULL;
- VIR_AUTOFREE(char *) outXmlData = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *inXmlData = NULL;
+ g_autofree char *outXmlData = NULL;
+ g_autofree char *actual = NULL;
VIR_AUTOUNREF(virDomainCheckpointDefPtr) def = NULL;
if (flags & TEST_REDEFINE)
testParseFormatFW(const void *opaque)
{
const char *filename = opaque;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_AUTOPTR(qemuFirmware) fw = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOPTR(virJSONValue) json = NULL;
- VIR_AUTOFREE(char *) expected = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *expected = NULL;
+ g_autofree char *actual = NULL;
if (virAsprintf(&path, "%s/qemufirmwaredata/%s",
abs_srcdir, filename) < 0)
static int
testFWPrecedence(const void *opaque G_GNUC_UNUSED)
{
- VIR_AUTOFREE(char *) fakehome = NULL;
+ g_autofree char *fakehome = NULL;
VIR_AUTOSTRINGLIST fwList = NULL;
size_t nfwList;
size_t i;
{
const struct testQueryJobsData *data = opaque;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(data->xmlopt);
- VIR_AUTOFREE(char *) filenameJSON = NULL;
- VIR_AUTOFREE(char *) fileJSON = NULL;
- VIR_AUTOFREE(char *) filenameResult = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *filenameJSON = NULL;
+ g_autofree char *fileJSON = NULL;
+ g_autofree char *filenameResult = NULL;
+ g_autofree char *actual = NULL;
qemuMonitorJobInfoPtr *jobs = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
size_t njobs = 0;
const char *usermsg)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) escapemsg = NULL;
- VIR_AUTOFREE(char *) jsonmsg = NULL;
+ g_autofree char *escapemsg = NULL;
+ g_autofree char *jsonmsg = NULL;
char *tmp;
if (!usermsg)
qemuMonitorTestAddUnexpectedErrorResponse(qemuMonitorTestPtr test,
const char *command)
{
- VIR_AUTOFREE(char *) msg = NULL;
+ g_autofree char *msg = NULL;
if (virAsprintf(&msg, "unexpected command: '%s'", command) < 0)
return -1;
const char *expectedcommand,
const char *actualcommand)
{
- VIR_AUTOFREE(char *) msg = NULL;
+ g_autofree char *msg = NULL;
if (virAsprintf(&msg, "expected command '%s' got '%s'",
expectedcommand, actualcommand) < 0)
qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...)
{
va_list msgargs;
- VIR_AUTOFREE(char *) msg = NULL;
- VIR_AUTOFREE(char *) jsonmsg = NULL;
+ g_autofree char *msg = NULL;
+ g_autofree char *jsonmsg = NULL;
int ret = -1;
va_start(msgargs, errmsg);
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
virJSONValuePtr schemaroot;
VIR_AUTOPTR(virJSONValue) emptyargs = NULL;
- VIR_AUTOFREE(char *) schemapath = NULL;
+ g_autofree char *schemapath = NULL;
if (!test->qapischema)
return 0;
const char *cmdstr)
{
struct qemuMonitorTestHandlerData *data = item->opaque;
- VIR_AUTOFREE(char *) reformatted = NULL;
- VIR_AUTOFREE(char *) errmsg = NULL;
+ g_autofree char *reformatted = NULL;
+ g_autofree char *errmsg = NULL;
VIR_AUTOPTR(virJSONValue) json = NULL;
virJSONValuePtr cmdargs;
const char *cmdname;
{
qemuDomainObjPrivatePtr priv;
VIR_AUTOUNREF(virDomainObjPtr) vm = NULL;
- VIR_AUTOFREE(char *) filename = NULL;
- VIR_AUTOFREE(char *) domxml = NULL;
- VIR_AUTOFREE(char *) latestCapsFile = NULL;
+ g_autofree char *filename = NULL;
+ g_autofree char *domxml = NULL;
+ g_autofree char *latestCapsFile = NULL;
if (virAsprintf(&filename, "%s/qemuxml2argvdata/%s.xml", abs_srcdir, xmlname) < 0)
return -1;
testParseFormatVU(const void *opaque)
{
const char *filename = opaque;
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
VIR_AUTOPTR(qemuVhostUser) vu = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
VIR_AUTOPTR(virJSONValue) json = NULL;
- VIR_AUTOFREE(char *) expected = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *expected = NULL;
+ g_autofree char *actual = NULL;
if (virAsprintf(&path, "%s/qemuvhostuserdata/%s",
abs_srcdir, filename) < 0)
static int
testVUPrecedence(const void *opaque G_GNUC_UNUSED)
{
- VIR_AUTOFREE(char *) fakehome = NULL;
+ g_autofree char *fakehome = NULL;
VIR_AUTOSTRINGLIST vuList = NULL;
size_t nvuList;
size_t i;
{
const struct testNodeInfoParserData *data = opaque;
collie_test test = data->data;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
{
const struct testVDIListParserData *data = opaque;
collie_test test = data->data;
- VIR_AUTOFREE(char *) output = NULL;
+ g_autofree char *output = NULL;
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
mymain(void)
{
int ret = 0;
- VIR_AUTOFREE(char *) poolxml = NULL;
- VIR_AUTOFREE(char *) volxml = NULL;
+ g_autofree char *poolxml = NULL;
+ g_autofree char *volxml = NULL;
collie_test node_info_tests[] = {
{"", -1, 0, 0},
(struct test_virStoragePoolCapsFormatData *) opaque;
virCapsPtr driverCaps = data->driverCaps;
VIR_AUTOUNREF(virStoragePoolCapsPtr) poolCaps = NULL;
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) poolCapsXML = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *poolCapsXML = NULL;
if (!(poolCaps = virStoragePoolCapsNew(driverCaps)))
virStoragePoolDefPtr def = NULL;
virStoragePoolObjPtr pool = NULL;
const char *defTypeStr;
- VIR_AUTOFREE(char *) actualCmdline = NULL;
- VIR_AUTOFREE(char *) src = NULL;
+ g_autofree char *actualCmdline = NULL;
+ g_autofree char *src = NULL;
VIR_AUTOPTR(virCommand) cmd = NULL;
if (!(def = virStoragePoolDefParseFile(poolxml)))
testCompareXMLToArgvHelper(const void *data)
{
const struct testInfo *info = data;
- VIR_AUTOFREE(char *) poolxml = NULL;
- VIR_AUTOFREE(char *) cmdline = NULL;
+ g_autofree char *poolxml = NULL;
+ g_autofree char *cmdline = NULL;
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
abs_srcdir, info->pool) < 0)
static int
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
{
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *actual = NULL;
VIR_AUTOPTR(virStoragePoolDef) dev = NULL;
if (!(dev = virStoragePoolDefParseFile(inxml)))
static int
testCompareXMLToXMLHelper(const void *data)
{
- VIR_AUTOFREE(char *) inxml = NULL;
- VIR_AUTOFREE(char *) outxml = NULL;
+ g_autofree char *inxml = NULL;
+ g_autofree char *outxml = NULL;
if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml",
abs_srcdir, (const char*)data) < 0 ||
int ret = -1;
virStoragePoolDefPtr def = NULL;
virStoragePoolObjPtr obj = NULL;
- VIR_AUTOFREE(char *) actualCmdline = NULL;
+ g_autofree char *actualCmdline = NULL;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL;
goto cleanup;
} else {
char *createCmdline = actualCmdline;
- VIR_AUTOFREE(char *) cvtCmdline = NULL;
+ g_autofree char *cvtCmdline = NULL;
int rc;
if (!(cvtCmdline = virCommandToString(cmd, false)))
testCompareXMLToArgvHelper(const void *data)
{
const struct testInfo *info = data;
- VIR_AUTOFREE(char *) poolxml = NULL;
- VIR_AUTOFREE(char *) inputpoolxml = NULL;
- VIR_AUTOFREE(char *) volxml = NULL;
- VIR_AUTOFREE(char *) inputvolxml = NULL;
- VIR_AUTOFREE(char *) cmdline = NULL;
+ g_autofree char *poolxml = NULL;
+ g_autofree char *inputpoolxml = NULL;
+ g_autofree char *volxml = NULL;
+ g_autofree char *inputvolxml = NULL;
+ g_autofree char *cmdline = NULL;
if (info->inputvol &&
virAsprintf(&inputvolxml, "%s/storagevolxml2xmlin/%s.xml",
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
const char *outxml, unsigned int flags)
{
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *actual = NULL;
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
VIR_AUTOPTR(virStorageVolDef) dev = NULL;
testCompareXMLToXMLHelper(const void *data)
{
const struct testInfo *info = data;
- VIR_AUTOFREE(char *) poolxml = NULL;
- VIR_AUTOFREE(char *) inxml = NULL;
- VIR_AUTOFREE(char *) outxml = NULL;
+ g_autofree char *poolxml = NULL;
+ g_autofree char *inxml = NULL;
+ g_autofree char *outxml = NULL;
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
abs_srcdir, info->pool) < 0 ||
virTestCompareToULL(unsigned long long expect,
unsigned long long actual)
{
- VIR_AUTOFREE(char *) expectStr = NULL;
- VIR_AUTOFREE(char *) actualStr = NULL;
+ g_autofree char *expectStr = NULL;
+ g_autofree char *actualStr = NULL;
if (virAsprintf(&expectStr, "%llu", expect) < 0)
return -1;
int gic = GIC_NONE;
char *capsarch = NULL;
char *capsver = NULL;
- VIR_AUTOFREE(char *) capsfile = NULL;
+ g_autofree char *capsfile = NULL;
int flag;
int ret = -1;
FILE *fopen(const char *path, const char *mode)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
PATH_OVERRIDE(newpath, path);
int access(const char *path, int mode)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
PATH_OVERRIDE(newpath, path);
int open(const char *path, int flags, ...)
# endif
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
va_list ap;
mode_t mode = 0;
DIR *opendir(const char *path)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
PATH_OVERRIDE(newpath, path);
int execv(const char *path, char *const argv[])
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
PATH_OVERRIDE(newpath, path);
int execve(const char *path, char *const argv[], char *const envp[])
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
PATH_OVERRIDE(newpath, path);
mymain(void)
{
int ret = 0;
- VIR_AUTOFREE(char *) fakerootdir = NULL;
+ g_autofree char *fakerootdir = NULL;
if (VIR_STRDUP_QUIET(fakerootdir, FAKEROOTDIRTEMPLATE) < 0) {
fprintf(stderr, "Out of memory\n");
{
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) injson = NULL;
- VIR_AUTOFREE(char *) infile = NULL;
- VIR_AUTOFREE(char *) indata = NULL;
- VIR_AUTOFREE(char *) outfile = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *infile = NULL;
+ g_autofree char *indata = NULL;
+ g_autofree char *outfile = NULL;
+ g_autofree char *actual = NULL;
if (virAsprintf(&infile, "%s/virjsondata/parse-%s-in.json",
abs_srcdir, info->name) < 0 ||
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) json = NULL;
const char *expectstr = info->expect ? info->expect : info->doc;
- VIR_AUTOFREE(char *) formatted = NULL;
+ g_autofree char *formatted = NULL;
json = virJSONValueFromString(info->doc);
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) json = NULL;
VIR_AUTOPTR(virJSONValue) name = NULL;
- VIR_AUTOFREE(char *) infile = NULL;
- VIR_AUTOFREE(char *) indata = NULL;
- VIR_AUTOFREE(char *) outfile = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *infile = NULL;
+ g_autofree char *indata = NULL;
+ g_autofree char *outfile = NULL;
+ g_autofree char *actual = NULL;
if (virAsprintf(&infile, "%s/virjsondata/add-remove-%s-in.json",
abs_srcdir, info->name) < 0 ||
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) json = NULL;
virJSONValuePtr value = NULL;
- VIR_AUTOFREE(char *) result = NULL;
+ g_autofree char *result = NULL;
int rc;
int number;
const char *str;
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) json = NULL;
VIR_AUTOPTR(virJSONValue) jsonCopy = NULL;
- VIR_AUTOFREE(char *) result = NULL;
- VIR_AUTOFREE(char *) resultCopy = NULL;
+ g_autofree char *result = NULL;
+ g_autofree char *resultCopy = NULL;
json = virJSONValueFromString(info->doc);
if (!json) {
const struct testInfo *info = data;
VIR_AUTOPTR(virJSONValue) injson = NULL;
VIR_AUTOPTR(virJSONValue) deflattened = NULL;
- VIR_AUTOFREE(char *) infile = NULL;
- VIR_AUTOFREE(char *) indata = NULL;
- VIR_AUTOFREE(char *) outfile = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *infile = NULL;
+ g_autofree char *indata = NULL;
+ g_autofree char *outfile = NULL;
+ g_autofree char *actual = NULL;
if (virAsprintf(&infile, "%s/virjsondata/deflatten-%s-in.json",
abs_srcdir, info->name) < 0 ||
VIR_AUTOPTR(virJSONValue) json = NULL;
VIR_AUTOPTR(virJSONValue) nestjson = NULL;
VIR_AUTOPTR(virJSONValue) parsejson = NULL;
- VIR_AUTOFREE(char *) neststr = NULL;
- VIR_AUTOFREE(char *) result = NULL;
+ g_autofree char *neststr = NULL;
+ g_autofree char *result = NULL;
const char *parsednestedstr;
if (virJSONValueObjectCreate(&nestjson,
int stat(const char *path, struct stat *sb)
# endif
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
#ifdef MOCK_STAT64
int stat64(const char *path, struct stat64 *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
int
__xstat(int ver, const char *path, struct stat *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
int
__xstat64(int ver, const char *path, struct stat64 *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
lstat(const char *path, struct stat *sb)
# endif
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
int
lstat64(const char *path, struct stat64 *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
int
__lxstat(int ver, const char *path, struct stat *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
int
__lxstat64(int ver, const char *path, struct stat64 *sb)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
virMockStatInit();
testInterfaceParseStats(const void *opaque)
{
const InterfaceParseStatsData *data = opaque;
- VIR_AUTOFREE(char *) filename = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *filename = NULL;
+ g_autofree char *buf = NULL;
virDomainInterfaceStatsStruct actual;
if (virAsprintf(&filename, "%s/virnetdevopenvswitchdata/%s",
ssize_t len)
{
int fd = -1;
- VIR_AUTOFREE(char *) filepath = NULL;
+ g_autofree char *filepath = NULL;
if (value && len == -1)
len = strlen(value);
make_dir(const char *path,
const char *name)
{
- VIR_AUTOFREE(char *) dirpath = NULL;
+ g_autofree char *dirpath = NULL;
if (virAsprintfQuiet(&dirpath, "%s/%s", path, name) < 0)
ABORT_OOM();
const char *name,
const char *target)
{
- VIR_AUTOFREE(char *) filepath = NULL;
+ g_autofree char *filepath = NULL;
if (virAsprintfQuiet(&filepath, "%s/%s", path, name) < 0)
ABORT_OOM();
{
int ret = -1;
int fd = -1;
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
if (virAsprintfQuiet(&newpath, "%s/%s", fakerootdir, path) < 0) {
errno = ENOMEM;
{
char *ret = NULL;
const char *prefix = "";
- VIR_AUTOFREE(char *) devid = NULL;
+ g_autofree char *devid = NULL;
if (faked)
prefix = fakerootdir;
const char *devid)
{
struct pciIommuGroup *iommuGroup;
- VIR_AUTOFREE(char *) iommuPath = NULL;
+ g_autofree char *iommuPath = NULL;
char tmp[256];
size_t i;
pci_device_new_from_stub(const struct pciDevice *data)
{
struct pciDevice *dev;
- VIR_AUTOFREE(char *) devpath = NULL;
- VIR_AUTOFREE(char *) devsympath = NULL;
- VIR_AUTOFREE(char *) id = NULL;
- VIR_AUTOFREE(char *) devid = NULL;
+ g_autofree char *devpath = NULL;
+ g_autofree char *devsympath = NULL;
+ g_autofree char *id = NULL;
+ g_autofree char *devid = NULL;
char *c;
- VIR_AUTOFREE(char *) configSrc = NULL;
+ g_autofree char *configSrc = NULL;
char tmp[256];
struct stat sb;
bool configSrcExists = false;
* file, and parallel VPATH builds must not stomp on the
* original; besides, 'make distcheck' requires the original
* to be read-only */
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
ssize_t len;
if ((len = virFileReadAll(configSrc, 4096, &buf)) < 0)
static int
pci_vfio_release_iommu(struct pciDevice *device)
{
- VIR_AUTOFREE(char *) vfiopath = NULL;
+ g_autofree char *vfiopath = NULL;
size_t i = 0;
for (i = 0; i < npciIommuGroups; i++) {
static int
pci_vfio_lock_iommu(struct pciDevice *device)
{
- VIR_AUTOFREE(char *) vfiopath = NULL;
+ g_autofree char *vfiopath = NULL;
int ret = -1;
size_t i = 0;
int fd = -1;
struct pciDriver *driver;
va_list args;
int vendor, device;
- VIR_AUTOFREE(char *) driverpath = NULL;
+ g_autofree char *driverpath = NULL;
if (VIR_ALLOC_QUIET(driver) < 0 ||
VIR_STRDUP_QUIET(driver->name, name) < 0 ||
static struct pciDriver *
pci_driver_find_by_driver_override(struct pciDevice *dev)
{
- VIR_AUTOFREE(char *) path = NULL;
+ g_autofree char *path = NULL;
char tmp[32];
size_t i;
pci_driver_bind(struct pciDriver *driver,
struct pciDevice *dev)
{
- VIR_AUTOFREE(char *) devid = NULL;
- VIR_AUTOFREE(char *) devpath = NULL;
- VIR_AUTOFREE(char *) driverpath = NULL;
+ g_autofree char *devid = NULL;
+ g_autofree char *devpath = NULL;
+ g_autofree char *driverpath = NULL;
if (dev->driver) {
/* Device already bound */
pci_driver_unbind(struct pciDriver *driver,
struct pciDevice *dev)
{
- VIR_AUTOFREE(char *) devid = NULL;
- VIR_AUTOFREE(char *) devpath = NULL;
- VIR_AUTOFREE(char *) driverpath = NULL;
+ g_autofree char *devid = NULL;
+ g_autofree char *devpath = NULL;
+ g_autofree char *driverpath = NULL;
if (dev->driver != driver) {
/* Device not bound to the @driver */
static void
init_env(void)
{
- VIR_AUTOFREE(char *) tmp = NULL;
+ g_autofree char *tmp = NULL;
if (!(fakerootdir = getenv("LIBVIRT_FAKE_ROOT_DIR")))
ABORT("Missing LIBVIRT_FAKE_ROOT_DIR env variable\n");
int
access(const char *path, int mode)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
init_syms();
open(const char *path, int flags, ...)
{
int ret;
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
init_syms();
int
__open_2(const char *path, int flags)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
int ret;
init_syms();
DIR *
opendir(const char *path)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
init_syms();
char *
virFileCanonicalizePath(const char *path)
{
- VIR_AUTOFREE(char *) newpath = NULL;
+ g_autofree char *newpath = NULL;
init_syms();
int ret = EXIT_FAILURE;
bool compat = false;
VIR_AUTOPTR(virCommand) cmd = NULL;
- VIR_AUTOFREE(char *) buf = NULL;
+ g_autofree char *buf = NULL;
qemuimg = virFindFileInPath("qemu-img");
if (!qemuimg)
virStorageSourcePtr elt;
size_t i = 0;
VIR_AUTOUNREF(virStorageSourcePtr) meta = NULL;
- VIR_AUTOFREE(char *) broken = NULL;
+ g_autofree char *broken = NULL;
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
if (!meta) {
elt = meta;
while (virStorageSourceIsBacking(elt)) {
- VIR_AUTOFREE(char *) expect = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *expect = NULL;
+ g_autofree char *actual = NULL;
if (i == data->nfiles) {
fprintf(stderr, "probed chain was too long\n");
testPathCanonicalize(const void *args)
{
const struct testPathCanonicalizeData *data = args;
- VIR_AUTOFREE(char *) canon = NULL;
+ g_autofree char *canon = NULL;
canon = virStorageFileCanonicalizePath(data->path,
testPathCanonicalizeReadlink,
testPathRelative(const void *args)
{
const struct testPathRelativeBacking *data = args;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *actual = NULL;
if (virStorageFileGetRelativeBackingPath(data->top,
data->base,
{
const struct testBackingParseData *data = args;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) xml = NULL;
+ g_autofree char *xml = NULL;
VIR_AUTOUNREF(virStorageSourcePtr) src = NULL;
int rc;
int erc = data->rv;
};
size_t i;
int ret = -1;
- VIR_AUTOFREE(char *) srcxmldata = NULL;
- VIR_AUTOFREE(char *) actual = NULL;
+ g_autofree char *srcxmldata = NULL;
+ g_autofree char *actual = NULL;
if (virTestLoadFile(data->srcxml, &srcxmldata) < 0)
goto cleanup;
VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
int ninterfaces;
- VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL;
+ g_autofree xmlNodePtr *interfaces = NULL;
size_t i;
unsigned int domainXMLFlags = 0;
char **ret = NULL;
virshControlPtr priv = ctl->privData;
VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
- VIR_AUTOFREE(xmlNodePtr *) disks = NULL;
+ g_autofree xmlNodePtr *disks = NULL;
int ndisks;
size_t i;
VIR_AUTOSTRINGLIST tmp = NULL;
virMacAddr macaddr;
char macstr[VIR_MAC_STRING_BUFLEN] = "";
int ninterfaces;
- VIR_AUTOFREE(xmlNodePtr *) interfaces = NULL;
- VIR_AUTOFREE(char *) xpath = NULL;
- VIR_AUTOFREE(char *) state = NULL;
+ g_autofree xmlNodePtr *interfaces = NULL;
+ g_autofree char *xpath = NULL;
+ g_autofree char *state = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
VIR_AUTOPTR(xmlDoc) xmldoc = NULL;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
int naliases;
- VIR_AUTOFREE(xmlNodePtr *) aliases = NULL;
+ g_autofree xmlNodePtr *aliases = NULL;
size_t i;
unsigned int domainXMLFlags = 0;
char **ret = NULL;
static char *
virshPagesizeNodeToString(xmlNodePtr node)
{
- VIR_AUTOFREE(char *) pagesize = NULL;
- VIR_AUTOFREE(char *) unit = NULL;
+ g_autofree char *pagesize = NULL;
+ g_autofree char *unit = NULL;
unsigned long long byteval = 0;
const char *suffix = NULL;
double size = 0;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
virshControlPtr priv = ctl->privData;
unsigned int npages = 0;
- VIR_AUTOFREE(xmlNodePtr *) pages = NULL;
+ g_autofree xmlNodePtr *pages = NULL;
VIR_AUTOPTR(xmlDoc) doc = NULL;
size_t i = 0;
const char *cellnum = NULL;
bool cellno = vshCommandOptBool(cmd, "cellno");
- VIR_AUTOFREE(char *) path = NULL;
- VIR_AUTOFREE(char *) cap_xml = NULL;
+ g_autofree char *path = NULL;
+ g_autofree char *cap_xml = NULL;
char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
VIR_AUTOPTR(xmlXPathContext) ctxt = NULL;
virshControlPtr priv = ctl->privData;
unsigned int ncells = 0;
- VIR_AUTOFREE(xmlNodePtr *) cells = NULL;
+ g_autofree xmlNodePtr *cells = NULL;
VIR_AUTOPTR(xmlDoc) doc = NULL;
size_t i = 0;
- VIR_AUTOFREE(char *) cap_xml = NULL;
+ g_autofree char *cap_xml = NULL;
char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
const char **options)
{
const size_t optionsLen = virStringListLength(options);
- VIR_AUTOFREE(char *) inputCopy = NULL;
+ g_autofree char *inputCopy = NULL;
VIR_AUTOSTRINGLIST inputList = NULL;
VIR_AUTOSTRINGLIST ret = NULL;
size_t nret = 0;
goto cleanup;
for (i = 0; i < ninterfaces; i++) {
- VIR_AUTOFREE(char *) type = NULL;
- VIR_AUTOFREE(char *) source = NULL;
- VIR_AUTOFREE(char *) target = NULL;
- VIR_AUTOFREE(char *) model = NULL;
- VIR_AUTOFREE(char *) mac = NULL;
+ g_autofree char *type = NULL;
+ g_autofree char *source = NULL;
+ g_autofree char *target = NULL;
+ g_autofree char *model = NULL;
+ g_autofree char *mac = NULL;
ctxt->node = interfaces[i];
type = virXPathString("string(./@type)", ctxt);
goto cleanup;
for (i = 0; i < ncpus; i++) {
- VIR_AUTOFREE(char *) pinInfo = NULL;
- VIR_AUTOFREE(char *) vcpuStr = NULL;
+ g_autofree char *pinInfo = NULL;
+ g_autofree char *vcpuStr = NULL;
if (got_vcpu && i != vcpu)
continue;
goto cleanup;
for (i = 0; i < niothreads; i++) {
- VIR_AUTOFREE(char *) pinInfo = NULL;
- VIR_AUTOFREE(char *) iothreadIdStr = NULL;
+ g_autofree char *pinInfo = NULL;
+ g_autofree char *iothreadIdStr = NULL;
if (virAsprintf(&iothreadIdStr, "%u", info[i]->iothread_id) < 0)
goto cleanup;
cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
{
VIR_AUTOPTR(virshDomain) dom = NULL;
- VIR_AUTOFREE(char *) monitor_cmd = NULL;
- VIR_AUTOFREE(char *) result = NULL;
+ g_autofree char *monitor_cmd = NULL;
+ g_autofree char *result = NULL;
unsigned int flags = 0;
const vshCmdOpt *opt = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
for (i = 0; i < ninfos; i++) {
virBuffer targetsBuff = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) targets = NULL;
+ g_autofree char *targets = NULL;
for (j = 0; j < info[i]->ndevAlias; j++)
virBufferAsprintf(&targetsBuff, "%s,", info[i]->devAlias[j]);
for (i = 0; i < nleases; i++) {
const char *typestr = NULL;
- VIR_AUTOFREE(char *) cidr_format = NULL;
+ g_autofree char *cidr_format = NULL;
virNetworkDHCPLeasePtr lease = leases[i];
time_t expirytime_tmp = lease->expirytime;
struct tm ts;
{
const unsigned int flags = 0; /* No flags so far */
virshControlPtr priv = ctl->privData;
- VIR_AUTOFREE(char *) caps = NULL;
+ g_autofree char *caps = NULL;
caps = virConnectGetStoragePoolCapabilities(priv->conn, flags);
if (!caps) {
const char *usageStr = virSecretUsageTypeToString(usageType);
char uuid[VIR_UUID_STRING_BUFLEN];
virBuffer buf = VIR_BUFFER_INITIALIZER;
- VIR_AUTOFREE(char *) usage = NULL;
+ g_autofree char *usage = NULL;
if (virSecretGetUUIDString(sec, uuid) < 0) {
vshError(ctl, "%s", _("Failed to get uuid of secret"));
goto cleanup;
for (i = 0; i < nsrvs; i++) {
- VIR_AUTOFREE(char *) idStr = NULL;
+ g_autofree char *idStr = NULL;
if (virAsprintf(&idStr, "%zu", i) < 0)
goto cleanup;
goto cleanup;
for (i = 0; i < nclts; i++) {
- VIR_AUTOFREE(char *) timestr = NULL;
- VIR_AUTOFREE(char *) idStr = NULL;
+ g_autofree char *timestr = NULL;
+ g_autofree char *idStr = NULL;
virAdmClientPtr client = clts[i];
id = virAdmClientGetID(client);
transport = virAdmClientGetTransport(client);