提交 29980231 编写于 作者: A Andrea Bolognani

conf: Get rid of virDomainCapsDevice

The struct contains a single boolean field, 'supported':
the meaning of this field is too generic to be limited to
devices only, and in fact it's already being used for
other things like loaders and OSs.

Instead of trying to come up with a more generic name just
get rid of the struct altogether.
上级 0d157957
...@@ -187,9 +187,9 @@ virDomainCapsStringValuesFormat(virBufferPtr buf, ...@@ -187,9 +187,9 @@ virDomainCapsStringValuesFormat(virBufferPtr buf,
#define FORMAT_PROLOGUE(item) \ #define FORMAT_PROLOGUE(item) \
do { \ do { \
virBufferAsprintf(buf, "<" #item " supported='%s'%s\n", \ virBufferAsprintf(buf, "<" #item " supported='%s'%s\n", \
item->device.supported ? "yes" : "no", \ item->supported ? "yes" : "no", \
item->device.supported ? ">" : "/>"); \ item->supported ? ">" : "/>"); \
if (!item->device.supported) \ if (!item->supported) \
return; \ return; \
virBufferAdjustIndent(buf, 2); \ virBufferAdjustIndent(buf, 2); \
} while (0) } while (0)
......
...@@ -44,16 +44,10 @@ struct _virDomainCapsStringValues { ...@@ -44,16 +44,10 @@ struct _virDomainCapsStringValues {
size_t nvalues; /* number of strings */ size_t nvalues; /* number of strings */
}; };
typedef struct _virDomainCapsDevice virDomainCapsDevice;
typedef virDomainCapsDevice *virDomainCapsDevicePtr;
struct _virDomainCapsDevice {
bool supported; /* true if <devtype> is supported by hypervisor */
};
typedef struct _virDomainCapsLoader virDomainCapsLoader; typedef struct _virDomainCapsLoader virDomainCapsLoader;
typedef virDomainCapsLoader *virDomainCapsLoaderPtr; typedef virDomainCapsLoader *virDomainCapsLoaderPtr;
struct _virDomainCapsLoader { struct _virDomainCapsLoader {
virDomainCapsDevice device; bool supported;
virDomainCapsStringValues values; /* Info about values for the element */ virDomainCapsStringValues values; /* Info about values for the element */
virDomainCapsEnum type; /* Info about virDomainLoader */ virDomainCapsEnum type; /* Info about virDomainLoader */
virDomainCapsEnum readonly; /* Info about readonly:virTristateBool */ virDomainCapsEnum readonly; /* Info about readonly:virTristateBool */
...@@ -62,14 +56,14 @@ struct _virDomainCapsLoader { ...@@ -62,14 +56,14 @@ struct _virDomainCapsLoader {
typedef struct _virDomainCapsOS virDomainCapsOS; typedef struct _virDomainCapsOS virDomainCapsOS;
typedef virDomainCapsOS *virDomainCapsOSPtr; typedef virDomainCapsOS *virDomainCapsOSPtr;
struct _virDomainCapsOS { struct _virDomainCapsOS {
virDomainCapsDevice device; bool supported;
virDomainCapsLoader loader; /* Info about virDomainLoaderDef */ virDomainCapsLoader loader; /* Info about virDomainLoaderDef */
}; };
typedef struct _virDomainCapsDeviceDisk virDomainCapsDeviceDisk; typedef struct _virDomainCapsDeviceDisk virDomainCapsDeviceDisk;
typedef virDomainCapsDeviceDisk *virDomainCapsDeviceDiskPtr; typedef virDomainCapsDeviceDisk *virDomainCapsDeviceDiskPtr;
struct _virDomainCapsDeviceDisk { struct _virDomainCapsDeviceDisk {
virDomainCapsDevice device; bool supported;
virDomainCapsEnum diskDevice; /* Info about virDomainDiskDevice enum values */ virDomainCapsEnum diskDevice; /* Info about virDomainDiskDevice enum values */
virDomainCapsEnum bus; /* Info about virDomainDiskBus enum values */ virDomainCapsEnum bus; /* Info about virDomainDiskBus enum values */
/* add new fields here */ /* add new fields here */
...@@ -78,7 +72,7 @@ struct _virDomainCapsDeviceDisk { ...@@ -78,7 +72,7 @@ struct _virDomainCapsDeviceDisk {
typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev; typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev;
typedef virDomainCapsDeviceHostdev *virDomainCapsDeviceHostdevPtr; typedef virDomainCapsDeviceHostdev *virDomainCapsDeviceHostdevPtr;
struct _virDomainCapsDeviceHostdev { struct _virDomainCapsDeviceHostdev {
virDomainCapsDevice device; bool supported;
virDomainCapsEnum mode; /* Info about virDomainHostdevMode */ virDomainCapsEnum mode; /* Info about virDomainHostdevMode */
virDomainCapsEnum startupPolicy; /* Info about virDomainStartupPolicy */ virDomainCapsEnum startupPolicy; /* Info about virDomainStartupPolicy */
virDomainCapsEnum subsysType; /* Info about virDomainHostdevSubsysType */ virDomainCapsEnum subsysType; /* Info about virDomainHostdevSubsysType */
......
...@@ -3908,7 +3908,7 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps, ...@@ -3908,7 +3908,7 @@ virQEMUCapsFillDomainLoaderCaps(virQEMUCapsPtr qemuCaps,
{ {
size_t i; size_t i;
capsLoader->device.supported = true; capsLoader->supported = true;
if (VIR_ALLOC_N(capsLoader->values.values, nloader) < 0) if (VIR_ALLOC_N(capsLoader->values.values, nloader) < 0)
return -1; return -1;
...@@ -3950,7 +3950,7 @@ virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps, ...@@ -3950,7 +3950,7 @@ virQEMUCapsFillDomainOSCaps(virQEMUCapsPtr qemuCaps,
{ {
virDomainCapsLoaderPtr capsLoader = &os->loader; virDomainCapsLoaderPtr capsLoader = &os->loader;
os->device.supported = true; os->supported = true;
if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, capsLoader, if (virQEMUCapsFillDomainLoaderCaps(qemuCaps, capsLoader,
loader, nloader) < 0) loader, nloader) < 0)
return -1; return -1;
...@@ -3963,7 +3963,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, ...@@ -3963,7 +3963,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps,
const char *machine, const char *machine,
virDomainCapsDeviceDiskPtr disk) virDomainCapsDeviceDiskPtr disk)
{ {
disk->device.supported = true; disk->supported = true;
/* QEMU supports all of these */ /* QEMU supports all of these */
VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice, VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice,
VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_DEVICE_DISK,
...@@ -3999,7 +3999,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, ...@@ -3999,7 +3999,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
hostdev->device.supported = true; hostdev->supported = true;
/* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */ /* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */
VIR_DOMAIN_CAPS_ENUM_SET(hostdev->mode, VIR_DOMAIN_CAPS_ENUM_SET(hostdev->mode,
VIR_DOMAIN_HOSTDEV_MODE_SUBSYS); VIR_DOMAIN_HOSTDEV_MODE_SUBSYS);
......
...@@ -65,9 +65,9 @@ fillAll(virDomainCapsPtr domCaps, ...@@ -65,9 +65,9 @@ fillAll(virDomainCapsPtr domCaps,
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev; virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
domCaps->maxvcpus = 255; domCaps->maxvcpus = 255;
os->device.supported = true; os->supported = true;
loader->device.supported = true; loader->supported = true;
SET_ALL_BITS(loader->type); SET_ALL_BITS(loader->type);
SET_ALL_BITS(loader->readonly); SET_ALL_BITS(loader->readonly);
if (fillStringValues(&loader->values, if (fillStringValues(&loader->values,
...@@ -76,11 +76,11 @@ fillAll(virDomainCapsPtr domCaps, ...@@ -76,11 +76,11 @@ fillAll(virDomainCapsPtr domCaps,
NULL) < 0) NULL) < 0)
return -1; return -1;
disk->device.supported = true; disk->supported = true;
SET_ALL_BITS(disk->diskDevice); SET_ALL_BITS(disk->diskDevice);
SET_ALL_BITS(disk->bus); SET_ALL_BITS(disk->bus);
hostdev->device.supported = true; hostdev->supported = true;
SET_ALL_BITS(hostdev->mode); SET_ALL_BITS(hostdev->mode);
SET_ALL_BITS(hostdev->startupPolicy); SET_ALL_BITS(hostdev->startupPolicy);
SET_ALL_BITS(hostdev->subsysType); SET_ALL_BITS(hostdev->subsysType);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册