[libvirt] [PATCH 0/8] cleanup: Use bool type instead of bitfield

This changes all the bitfield into bool type in domain_conf.h, except domain->autostart, domain->persistent, and domain->updated, as the public APIs like virDomainIsPersistent returns domain->persistent as integer, they can be changed internally, but not that deserved. Osier Yang (8): Cleanup: Change datatype of hostdev->managed to boolean Cleanup: Change datatype of origstate's members into boolean cleanup: Change datatype of hostdev->missing to boolean cleanup: Change datatype of auth->expires to boolean cleanup: Change datatype of disk->shared to boolean cleanup: Change datatype of disk->transient to boolean cleanup: Change datatype of disk->readonly to boolean cleanup: Change datatype of fs->readonly to boolean src/conf/domain_conf.c | 20 ++++++------- src/conf/domain_conf.h | 20 ++++++------- src/lxc/lxc_hostdev.c | 2 +- src/parallels/parallels_driver.c | 2 +- src/qemu/qemu_command.c | 10 +++---- src/qemu/qemu_hostdev.c | 2 +- src/util/virpci.c | 64 ++++++++++++++++++++-------------------- src/util/virpci.h | 8 ++--- src/vbox/vbox_tmpl.c | 12 ++++---- src/xenxs/xen_sxpr.c | 8 ++--- src/xenxs/xen_xm.c | 8 ++--- 11 files changed, 78 insertions(+), 78 deletions(-) -- 1.8.1.4

--- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 4 ++-- src/util/virpci.c | 6 +++--- src/util/virpci.h | 2 +- src/xenxs/xen_sxpr.c | 2 +- src/xenxs/xen_xm.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cf955c7..bb9d9f5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3658,7 +3658,7 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, */ if ((managed = virXMLPropString(node, "managed"))!= NULL) { if (STREQ(managed, "yes")) - def->managed = 1; + def->managed = true; } /* @type is passed in from the caller rather than read from the diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9ecea85..0df92ef 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -442,7 +442,7 @@ struct _virDomainHostdevDef { virDomainDeviceDef parent; /* higher level Def containing this */ int mode; /* enum virDomainHostdevMode */ int startupPolicy; /* enum virDomainStartupPolicy */ - unsigned int managed : 1; + bool managed; unsigned int missing : 1; bool readonly; /* readonly is only used for scsi hostdev */ union { diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 41a2dfd..3ba989d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8558,7 +8558,7 @@ qemuParseCommandLinePCI(const char *val) } def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - def->managed = 1; + def->managed = true; def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; def->source.subsys.u.pci.bus = bus; def->source.subsys.u.pci.slot = slot; @@ -8619,7 +8619,7 @@ qemuParseCommandLineUSB(const char *val) } def->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - def->managed = 0; + def->managed = false; def->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB; if (*end == '.') { def->source.subsys.u.usb.bus = first; diff --git a/src/util/virpci.c b/src/util/virpci.c index a0da1cd..805a633 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -65,7 +65,7 @@ struct _virPCIDevice { unsigned pci_pm_cap_pos; unsigned has_flr : 1; unsigned has_pm_reset : 1; - unsigned managed : 1; + bool managed; /* used by reattach function */ unsigned unbind_from_stub : 1; @@ -1453,9 +1453,9 @@ virPCIDeviceGetName(virPCIDevicePtr dev) return dev->name; } -void virPCIDeviceSetManaged(virPCIDevicePtr dev, unsigned managed) +void virPCIDeviceSetManaged(virPCIDevicePtr dev, bool managed) { - dev->managed = !!managed; + dev->managed = managed; } unsigned virPCIDeviceGetManaged(virPCIDevicePtr dev) diff --git a/src/util/virpci.h b/src/util/virpci.h index cf2aecd..9ea721a 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -61,7 +61,7 @@ int virPCIDeviceReset(virPCIDevicePtr dev, virPCIDeviceListPtr inactiveDevs); void virPCIDeviceSetManaged(virPCIDevice *dev, - unsigned managed); + bool managed); unsigned virPCIDeviceGetManaged(virPCIDevice *dev); void virPCIDeviceSetUsedBy(virPCIDevice *dev, const char *used_by); diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index cc4225b..7ed1482 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -1087,7 +1087,7 @@ xenParseSxprPCI(virDomainDefPtr def, goto error; dev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; - dev->managed = 0; + dev->managed = false; dev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; dev->source.subsys.u.pci.domain = domainID; dev->source.subsys.u.pci.bus = busID; diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 34103b9..14e26c3 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -875,7 +875,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (!(hostdev = virDomainHostdevDefAlloc())) goto cleanup; - hostdev->managed = 0; + hostdev->managed = false; hostdev->source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI; hostdev->source.subsys.u.pci.domain = domainID; hostdev->source.subsys.u.pci.bus = busID; -- 1.8.1.4

Members of struct virPCIDevice are changed together. --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 6 +++--- src/util/virpci.c | 58 +++++++++++++++++++++++++------------------------- src/util/virpci.h | 6 +++--- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bb9d9f5..a2c3a64 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3571,11 +3571,11 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node, while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "unbind")) { - def->states.pci.unbind_from_stub = 1; + def->states.pci.unbind_from_stub = true; } else if (xmlStrEqual(cur->name, BAD_CAST "removeslot")) { - def->states.pci.remove_slot = 1; + def->states.pci.remove_slot = true; } else if (xmlStrEqual(cur->name, BAD_CAST "reprobe")) { - def->states.pci.reprobe = 1; + def->states.pci.reprobe = true; } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported element '%s' of 'origstates'"), diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0df92ef..09ce261 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -345,17 +345,17 @@ struct _virDomainHostdevOrigStates { /* Does the device need to unbind from stub when * reattaching to host? */ - unsigned int unbind_from_stub : 1; + bool unbind_from_stub; /* Does it need to use remove_slot when reattaching * the device to host? */ - unsigned int remove_slot : 1; + bool remove_slot; /* Does it need to reprobe driver for the device when * reattaching to host? */ - unsigned int reprobe :1; + bool reprobe; } pci; /* Perhaps 'usb' in future */ diff --git a/src/util/virpci.c b/src/util/virpci.c index 805a633..d431e81 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -63,14 +63,14 @@ struct _virPCIDevice { unsigned pcie_cap_pos; unsigned pci_pm_cap_pos; - unsigned has_flr : 1; - unsigned has_pm_reset : 1; + bool has_flr; + bool has_pm_reset; bool managed; /* used by reattach function */ - unsigned unbind_from_stub : 1; - unsigned remove_slot : 1; - unsigned reprobe : 1; + bool unbind_from_stub; + bool remove_slot; + bool reprobe; }; struct _virPCIDeviceList { @@ -776,8 +776,8 @@ virPCIDeviceInit(virPCIDevicePtr dev, int cfgfd) flr = virPCIDeviceDetectFunctionLevelReset(dev, cfgfd); if (flr < 0) return flr; - dev->has_flr = flr; - dev->has_pm_reset = virPCIDeviceDetectPowerManagementReset(dev, cfgfd); + dev->has_flr = !!flr; + dev->has_pm_reset = !!virPCIDeviceDetectPowerManagementReset(dev, cfgfd); return 0; } @@ -935,7 +935,7 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev, const char *driver) goto cleanup; } } - dev->unbind_from_stub = 0; + dev->unbind_from_stub = false; remove_slot: if (!dev->remove_slot) @@ -952,7 +952,7 @@ remove_slot: dev->name, driver); goto cleanup; } - dev->remove_slot = 0; + dev->remove_slot = false; reprobe: if (!dev->reprobe) { @@ -982,9 +982,9 @@ reprobe: cleanup: /* do not do it again */ - dev->unbind_from_stub = 0; - dev->remove_slot = 0; - dev->reprobe = 0; + dev->unbind_from_stub = false; + dev->remove_slot = false; + dev->reprobe = false; VIR_FREE(drvdir); VIR_FREE(path); @@ -999,7 +999,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) int result = -1; char *drvdir = NULL; char *path = NULL; - int reprobe = 0; + int reprobe = false; /* check whether the device is already bound to a driver */ if (virPCIDriverDir(&drvdir, driver) < 0 || @@ -1013,7 +1013,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) result = 0; goto cleanup; } - reprobe = 1; + reprobe = true; } /* Add the PCI device ID to the stub's dynamic ID table; @@ -1044,8 +1044,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) } if (virFileLinkPointsTo(path, drvdir)) { - dev->unbind_from_stub = 1; - dev->remove_slot = 1; + dev->unbind_from_stub = true; + dev->remove_slot = true; goto remove_id; } @@ -1087,7 +1087,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) dev->name, driver); goto remove_id; } - dev->remove_slot = 1; + dev->remove_slot = true; if (virPCIDriverFile(&path, driver, "bind") < 0) { goto remove_id; @@ -1099,7 +1099,7 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev, const char *driver) dev->name, driver); goto remove_id; } - dev->unbind_from_stub = 1; + dev->unbind_from_stub = true; } remove_id: @@ -1112,7 +1112,7 @@ remove_id: VIR_WARN("Could not remove PCI ID '%s' from %s, and the device " "cannot be probed again.", dev->id, driver); } - dev->reprobe = 0; + dev->reprobe = false; goto cleanup; } @@ -1126,7 +1126,7 @@ remove_id: VIR_WARN("Failed to remove PCI ID '%s' from %s, and the device " "cannot be probed again.", dev->id, driver); } - dev->reprobe = 0; + dev->reprobe = false; goto cleanup; } @@ -1470,9 +1470,9 @@ virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev) } void -virPCIDeviceSetUnbindFromStub(virPCIDevicePtr dev, unsigned unbind) +virPCIDeviceSetUnbindFromStub(virPCIDevicePtr dev, bool unbind) { - dev->unbind_from_stub = !!unbind; + dev->unbind_from_stub = unbind; } unsigned @@ -1482,9 +1482,9 @@ virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev) } void -virPCIDeviceSetRemoveSlot(virPCIDevicePtr dev, unsigned remove_slot) +virPCIDeviceSetRemoveSlot(virPCIDevicePtr dev, bool remove_slot) { - dev->remove_slot = !!remove_slot; + dev->remove_slot = remove_slot; } unsigned @@ -1494,9 +1494,9 @@ virPCIDeviceGetReprobe(virPCIDevicePtr dev) } void -virPCIDeviceSetReprobe(virPCIDevicePtr dev, unsigned reprobe) +virPCIDeviceSetReprobe(virPCIDevicePtr dev, bool reprobe) { - dev->reprobe = !!reprobe; + dev->reprobe = reprobe; } void @@ -1513,9 +1513,9 @@ virPCIDeviceGetUsedBy(virPCIDevicePtr dev) void virPCIDeviceReattachInit(virPCIDevicePtr pci) { - pci->unbind_from_stub = 1; - pci->remove_slot = 1; - pci->reprobe = 1; + pci->unbind_from_stub = true; + pci->remove_slot = true; + pci->reprobe = true; } diff --git a/src/util/virpci.h b/src/util/virpci.h index 9ea721a..0c4a8d2 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -68,13 +68,13 @@ void virPCIDeviceSetUsedBy(virPCIDevice *dev, const char *virPCIDeviceGetUsedBy(virPCIDevice *dev); unsigned virPCIDeviceGetUnbindFromStub(virPCIDevicePtr dev); void virPCIDeviceSetUnbindFromStub(virPCIDevice *dev, - unsigned unbind); + bool unbind); unsigned virPCIDeviceGetRemoveSlot(virPCIDevicePtr dev); void virPCIDeviceSetRemoveSlot(virPCIDevice *dev, - unsigned remove_slot); + bool remove_slot); unsigned virPCIDeviceGetReprobe(virPCIDevicePtr dev); void virPCIDeviceSetReprobe(virPCIDevice *dev, - unsigned reprobe); + bool reprobe); void virPCIDeviceReattachInit(virPCIDevice *dev); -- 1.8.1.4

--- src/conf/domain_conf.h | 2 +- src/lxc/lxc_hostdev.c | 2 +- src/qemu/qemu_hostdev.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 09ce261..d8c1f6e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -443,7 +443,7 @@ struct _virDomainHostdevDef { int mode; /* enum virDomainHostdevMode */ int startupPolicy; /* enum virDomainStartupPolicy */ bool managed; - unsigned int missing : 1; + bool missing; bool readonly; /* readonly is only used for scsi hostdev */ union { virDomainHostdevSubsys subsys; diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c index 53a1a31..0ce5d05 100644 --- a/src/lxc/lxc_hostdev.c +++ b/src/lxc/lxc_hostdev.c @@ -207,7 +207,7 @@ virLXCFindHostdevUSBDevice(virDomainHostdevDefPtr hostdev, out: if (!*usb) - hostdev->missing = 1; + hostdev->missing = true; return 0; } diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c index bac38b5..0db9ddd 100644 --- a/src/qemu/qemu_hostdev.c +++ b/src/qemu/qemu_hostdev.c @@ -739,7 +739,7 @@ qemuFindHostdevUSBDevice(virDomainHostdevDefPtr hostdev, out: if (!*usb) - hostdev->missing = 1; + hostdev->missing = true; return 0; } -- 1.8.1.4

--- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/parallels/parallels_driver.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a2c3a64..a54e6ca 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7184,7 +7184,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, tm.tm_mon--; /* Humans start months at 1, computers at 0 */ def->validTo = timegm(&tm); - def->expires = 1; + def->expires = true; } if (connected) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d8c1f6e..732bacc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1235,7 +1235,7 @@ typedef struct _virDomainGraphicsAuthDef virDomainGraphicsAuthDef; typedef virDomainGraphicsAuthDef *virDomainGraphicsAuthDefPtr; struct _virDomainGraphicsAuthDef { char *passwd; - unsigned int expires: 1; /* Whether there is an expiry time set */ + bool expires; /* Whether there is an expiry time set */ time_t validTo; /* seconds since epoch */ int connected; /* action if connected */ }; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index c524bf1..451e948 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -629,7 +629,7 @@ parallelsAddVNCInfo(virDomainDefPtr def, virJSONValuePtr jobj_root) gr->data.vnc.keymap = NULL; gr->data.vnc.socket = NULL; gr->data.vnc.auth.passwd = NULL; - gr->data.vnc.auth.expires = 0; + gr->data.vnc.auth.expires = false; gr->data.vnc.auth.connected = 0; if (!(tmp = virJSONValueObjectGetString(jobj, "address"))) { -- 1.8.1.4

--- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- src/xenxs/xen_sxpr.c | 2 +- src/xenxs/xen_xm.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a54e6ca..c595401 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4732,7 +4732,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { def->readonly = 1; } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { - def->shared = 1; + def->shared = true; } else if (xmlStrEqual(cur->name, BAD_CAST "transient")) { def->transient = 1; } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) && diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 732bacc..2d66b39 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -683,7 +683,7 @@ struct _virDomainDiskDef { int snapshot; /* enum virDomainSnapshotLocation, snapshot_conf.h */ int startupPolicy; /* enum virDomainStartupPolicy */ unsigned int readonly : 1; - unsigned int shared : 1; + bool shared; unsigned int transient : 1; virDomainDeviceInfo info; virStorageEncryptionPtr encryption; diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index 7ed1482..4bd1f47 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -509,7 +509,7 @@ xenParseSxprDisks(virDomainDefPtr def, disk->readonly = 1; if (mode && strchr(mode, '!')) - disk->shared = 1; + disk->shared = true; if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) goto no_memory; diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 14e26c3..c68bee0 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -613,7 +613,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, disk->readonly = 1; else if ((STREQ(head, "w!")) || (STREQ(head, "!"))) - disk->shared = 1; + disk->shared = true; /* Maintain list in sorted order according to target device name */ if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) -- 1.8.1.4

--- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c595401..753d248 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4734,7 +4734,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { def->shared = true; } else if (xmlStrEqual(cur->name, BAD_CAST "transient")) { - def->transient = 1; + def->transient = true; } else if ((flags & VIR_DOMAIN_XML_INTERNAL_STATUS) && xmlStrEqual(cur->name, BAD_CAST "state")) { /* Legacy back-compat. Don't add any more attributes here */ diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2d66b39..a951996 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -684,7 +684,7 @@ struct _virDomainDiskDef { int startupPolicy; /* enum virDomainStartupPolicy */ unsigned int readonly : 1; bool shared; - unsigned int transient : 1; + bool transient; virDomainDeviceInfo info; virStorageEncryptionPtr encryption; bool rawio_specified; -- 1.8.1.4

--- src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 6 +++--- src/vbox/vbox_tmpl.c | 12 ++++++------ src/xenxs/xen_sxpr.c | 4 ++-- src/xenxs/xen_xm.c | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 753d248..afd4467 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4730,7 +4730,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { - def->readonly = 1; + def->readonly = true; } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { def->shared = true; } else if (xmlStrEqual(cur->name, BAD_CAST "transient")) { @@ -4858,7 +4858,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, /* Force CDROM to be listed as read only */ if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - def->readonly = 1; + def->readonly = true; if ((def->device == VIR_DOMAIN_DISK_DEVICE_DISK || def->device == VIR_DOMAIN_DISK_DEVICE_LUN) && diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a951996..51e605a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -682,7 +682,7 @@ struct _virDomainDiskDef { int copy_on_read; int snapshot; /* enum virDomainSnapshotLocation, snapshot_conf.h */ int startupPolicy; /* enum virDomainStartupPolicy */ - unsigned int readonly : 1; + bool readonly; bool shared; bool transient; virDomainDeviceInfo info; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3ba989d..d899239 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8137,7 +8137,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, } else if (STREQ(keywords[i], "media")) { if (STREQ(values[i], "cdrom")) { def->device = VIR_DOMAIN_DISK_DEVICE_CDROM; - def->readonly = 1; + def->readonly = true; } else if (STREQ(values[i], "floppy")) def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; } else if (STREQ(keywords[i], "format")) { @@ -8196,7 +8196,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, } } else if (STREQ(keywords[i], "readonly")) { if ((values[i] == NULL) || STREQ(values[i], "on")) - def->readonly = 1; + def->readonly = true; } else if (STREQ(keywords[i], "aio")) { if ((def->iomode = virDomainDiskIoTypeFromString(values[i])) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -9303,7 +9303,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, disk->dst = strdup("hdc"); if (!disk->dst) goto no_memory; - disk->readonly = 1; + disk->readonly = true; } else { if (STRPREFIX(arg, "-fd")) { disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0248ee0..ff8f9d1 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2647,7 +2647,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { hardDiskPM->vtbl->GetType(hardDiskPM, &hddType); if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->readonly = 1; + def->disks[hddNum]->readonly = true; def->disks[hddNum]->src = strdup(hddlocation); def->disks[hddNum]->dst = strdup("hda"); hddNum++; @@ -2668,7 +2668,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { hardDiskPS->vtbl->GetType(hardDiskPS, &hddType); if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->readonly = 1; + def->disks[hddNum]->readonly = true; def->disks[hddNum]->src = strdup(hddlocation); def->disks[hddNum]->dst = strdup("hdb"); hddNum++; @@ -2689,7 +2689,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { hardDiskSS->vtbl->GetType(hardDiskSS, &hddType); if (hddType == HardDiskType_Immutable) - def->disks[hddNum]->readonly = 1; + def->disks[hddNum]->readonly = true; def->disks[hddNum]->src = strdup(hddlocation); def->disks[hddNum]->dst = strdup("hdd"); hddNum++; @@ -2830,7 +2830,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) { medium->vtbl->GetReadOnly(medium, &readOnly); if (readOnly == PR_TRUE) - def->disks[diskCount]->readonly = 1; + def->disks[diskCount]->readonly = true; def->disks[diskCount]->type = VIR_DOMAIN_DISK_TYPE_FILE; @@ -3118,7 +3118,7 @@ sharedFoldersCleanup: def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_CDROM; def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_IDE; def->disks[def->ndisks - 1]->type = VIR_DOMAIN_DISK_TYPE_FILE; - def->disks[def->ndisks - 1]->readonly = 1; + def->disks[def->ndisks - 1]->readonly = true; def->disks[def->ndisks - 1]->src = strdup(location); def->disks[def->ndisks - 1]->dst = strdup("hdc"); } else { @@ -3165,7 +3165,7 @@ sharedFoldersCleanup: def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY; def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_FDC; def->disks[def->ndisks - 1]->type = VIR_DOMAIN_DISK_TYPE_FILE; - def->disks[def->ndisks - 1]->readonly = 0; + def->disks[def->ndisks - 1]->readonly = false; def->disks[def->ndisks - 1]->src = strdup(location); def->disks[def->ndisks - 1]->dst = strdup("fda"); } else { diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index 4bd1f47..a179612 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -506,7 +506,7 @@ xenParseSxprDisks(virDomainDefPtr def, if (mode && strchr(mode, 'r')) - disk->readonly = 1; + disk->readonly = true; if (mode && strchr(mode, '!')) disk->shared = true; @@ -1371,7 +1371,7 @@ xenParseSxpr(const struct sexpr *root, goto no_memory; } disk->bus = VIR_DOMAIN_DISK_BUS_IDE; - disk->readonly = 1; + disk->readonly = true; if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) { virDomainDiskDefFree(disk); diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index c68bee0..b2e7645 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -610,7 +610,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (STREQ(head, "r") || STREQ(head, "ro")) - disk->readonly = 1; + disk->readonly = true; else if ((STREQ(head, "w!")) || (STREQ(head, "!"))) disk->shared = true; @@ -643,7 +643,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion, if (!(disk->dst = strdup("hdc"))) goto no_memory; disk->bus = VIR_DOMAIN_DISK_BUS_IDE; - disk->readonly = 1; + disk->readonly = true; if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) goto no_memory; -- 1.8.1.4

--- src/conf/domain_conf.c | 2 +- src/conf/domain_conf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index afd4467..9f8687e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5489,7 +5489,7 @@ virDomainFSDefParseXML(xmlNodePtr node, xmlStrEqual(cur->name, BAD_CAST "target")) { target = virXMLPropString(cur, "dir"); } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { - def->readonly = 1; + def->readonly = true; } else if (!fsdriver && xmlStrEqual(cur->name, BAD_CAST "driver")) { fsdriver = virXMLPropString(cur, "type"); wrpolicy = virXMLPropString(cur, "wrpolicy"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 51e605a..78a6c16 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -807,7 +807,7 @@ struct _virDomainFSDef { unsigned long long usage; char *src; char *dst; - unsigned int readonly : 1; + bool readonly; virDomainDeviceInfo info; unsigned long long space_hard_limit; /* in bytes */ unsigned long long space_soft_limit; /* in bytes */ -- 1.8.1.4

On 04/10/2013 12:32 PM, Osier Yang wrote:
This changes all the bitfield into bool type in domain_conf.h, except domain->autostart, domain->persistent, and domain->updated, as the public APIs like virDomainIsPersistent returns domain->persistent as integer, they can be changed internally, but not that deserved.
Osier Yang (8): Cleanup: Change datatype of hostdev->managed to boolean Cleanup: Change datatype of origstate's members into boolean cleanup: Change datatype of hostdev->missing to boolean cleanup: Change datatype of auth->expires to boolean cleanup: Change datatype of disk->shared to boolean cleanup: Change datatype of disk->transient to boolean cleanup: Change datatype of disk->readonly to boolean cleanup: Change datatype of fs->readonly to boolean
For some reason these patches wouldn't apply to the head of master, but they seem very straightforward and mechanical, and I think it's a useful cleanup (if for no other reason that to avoid perpetuating the idea of using bitfields). Assuming that you've run both make check and make syntax-check successfully, ACK for the series.

On 11/04/13 09:52, Laine Stump wrote:
This changes all the bitfield into bool type in domain_conf.h, except domain->autostart, domain->persistent, and domain->updated, as the public APIs like virDomainIsPersistent returns domain->persistent as integer, they can be changed internally, but not that deserved.
Osier Yang (8): Cleanup: Change datatype of hostdev->managed to boolean Cleanup: Change datatype of origstate's members into boolean cleanup: Change datatype of hostdev->missing to boolean cleanup: Change datatype of auth->expires to boolean cleanup: Change datatype of disk->shared to boolean cleanup: Change datatype of disk->transient to boolean cleanup: Change datatype of disk->readonly to boolean cleanup: Change datatype of fs->readonly to boolean For some reason these patches wouldn't apply to the head of master, but
On 04/10/2013 12:32 PM, Osier Yang wrote: they seem very straightforward and mechanical, and I think it's a useful cleanup (if for no other reason that to avoid perpetuating the idea of using bitfields).
I forgot I was on top of updating scsi-generic passthrough patches.
Assuming that you've run both make check and make syntax-check successfully, ACK for the series.
Rebased, and make check/make syntax-check work fine, pushed. Thanks. Osier
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Laine Stump
-
Osier Yang