mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
Export virDomainGetBlkioParametersAssignFromDef
Move qemuDomainGetBlkioParametersAssignFromDef into domain_conf and export it, to allow reuse in the LXC driver.
This commit is contained in:
parent
e74bbe5caf
commit
32e6339c19
@ -24702,3 +24702,54 @@ virDomainObjGetShortName(virDomainObjPtr vm)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
|
||||||
|
virTypedParameterPtr params,
|
||||||
|
int *nparams,
|
||||||
|
int maxparams)
|
||||||
|
{
|
||||||
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
char *data = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
#define VIR_BLKIO_ASSIGN(param, format, name) \
|
||||||
|
if (*nparams < maxparams) { \
|
||||||
|
for (i = 0; i < def->blkio.ndevices; i++) { \
|
||||||
|
if (!def->blkio.devices[i].param) \
|
||||||
|
continue; \
|
||||||
|
virBufferAsprintf(&buf, "%s," format ",", \
|
||||||
|
def->blkio.devices[i].path, \
|
||||||
|
def->blkio.devices[i].param); \
|
||||||
|
} \
|
||||||
|
virBufferTrim(&buf, ",", -1); \
|
||||||
|
if (virBufferCheckError(&buf) < 0) \
|
||||||
|
goto error; \
|
||||||
|
data = virBufferContentAndReset(&buf); \
|
||||||
|
if (virTypedParameterAssign(&(params[(*nparams)++]), name, \
|
||||||
|
VIR_TYPED_PARAM_STRING, data) < 0) \
|
||||||
|
goto error; \
|
||||||
|
VIR_FREE(data); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* blkiotune.device_weight */
|
||||||
|
VIR_BLKIO_ASSIGN(weight, "%u", VIR_DOMAIN_BLKIO_DEVICE_WEIGHT);
|
||||||
|
/* blkiotune.device_read_iops */
|
||||||
|
VIR_BLKIO_ASSIGN(riops, "%u", VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS);
|
||||||
|
/* blkiotune.device_write_iops */
|
||||||
|
VIR_BLKIO_ASSIGN(wiops, "%u", VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS);
|
||||||
|
/* blkiotune.device_read_bps */
|
||||||
|
VIR_BLKIO_ASSIGN(rbps, "%llu", VIR_DOMAIN_BLKIO_DEVICE_READ_BPS);
|
||||||
|
/* blkiotune.device_write_bps */
|
||||||
|
VIR_BLKIO_ASSIGN(wbps, "%llu", VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS);
|
||||||
|
|
||||||
|
#undef VIR_BLKIO_ASSIGN
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
VIR_FREE(data);
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
# include "virprocess.h"
|
# include "virprocess.h"
|
||||||
# include "virgic.h"
|
# include "virgic.h"
|
||||||
# include "virperf.h"
|
# include "virperf.h"
|
||||||
|
# include "virtypedparam.h"
|
||||||
|
|
||||||
/* forward declarations of all device types, required by
|
/* forward declarations of all device types, required by
|
||||||
* virDomainDeviceDef
|
* virDomainDeviceDef
|
||||||
@ -3083,4 +3084,9 @@ bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
|
|||||||
|
|
||||||
char *virDomainObjGetShortName(virDomainObjPtr vm);
|
char *virDomainObjGetShortName(virDomainObjPtr vm);
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
|
||||||
|
virTypedParameterPtr params,
|
||||||
|
int *nparams,
|
||||||
|
int maxparams);
|
||||||
#endif /* __DOMAIN_CONF_H */
|
#endif /* __DOMAIN_CONF_H */
|
||||||
|
@ -93,6 +93,7 @@ virDomainCCWAddressReleaseAddr;
|
|||||||
virDomainCCWAddressSetCreate;
|
virDomainCCWAddressSetCreate;
|
||||||
virDomainCCWAddressSetFree;
|
virDomainCCWAddressSetFree;
|
||||||
virDomainCCWAddressValidate;
|
virDomainCCWAddressValidate;
|
||||||
|
virDomainGetBlkioParametersAssignFromDef;
|
||||||
virDomainPCIAddressAsString;
|
virDomainPCIAddressAsString;
|
||||||
virDomainPCIAddressBusSetModel;
|
virDomainPCIAddressBusSetModel;
|
||||||
virDomainPCIAddressEnsureAddr;
|
virDomainPCIAddressEnsureAddr;
|
||||||
|
@ -9102,57 +9102,6 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
|
||||||
qemuDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
|
|
||||||
virTypedParameterPtr params,
|
|
||||||
int *nparams,
|
|
||||||
int maxparams)
|
|
||||||
{
|
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
||||||
char *data = NULL;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
#define QEMU_BLKIO_ASSIGN(param, format, name) \
|
|
||||||
if (*nparams < maxparams) { \
|
|
||||||
for (i = 0; i < def->blkio.ndevices; i++) { \
|
|
||||||
if (!def->blkio.devices[i].param) \
|
|
||||||
continue; \
|
|
||||||
virBufferAsprintf(&buf, "%s," format ",", \
|
|
||||||
def->blkio.devices[i].path, \
|
|
||||||
def->blkio.devices[i].param); \
|
|
||||||
} \
|
|
||||||
virBufferTrim(&buf, ",", -1); \
|
|
||||||
if (virBufferCheckError(&buf) < 0) \
|
|
||||||
goto error; \
|
|
||||||
data = virBufferContentAndReset(&buf); \
|
|
||||||
if (virTypedParameterAssign(&(params[(*nparams)++]), name, \
|
|
||||||
VIR_TYPED_PARAM_STRING, data) < 0) \
|
|
||||||
goto error; \
|
|
||||||
VIR_FREE(data); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* blkiotune.device_weight */
|
|
||||||
QEMU_BLKIO_ASSIGN(weight, "%u", VIR_DOMAIN_BLKIO_DEVICE_WEIGHT);
|
|
||||||
/* blkiotune.device_read_iops */
|
|
||||||
QEMU_BLKIO_ASSIGN(riops, "%u", VIR_DOMAIN_BLKIO_DEVICE_READ_IOPS);
|
|
||||||
/* blkiotune.device_write_iops */
|
|
||||||
QEMU_BLKIO_ASSIGN(wiops, "%u", VIR_DOMAIN_BLKIO_DEVICE_WRITE_IOPS);
|
|
||||||
/* blkiotune.device_read_bps */
|
|
||||||
QEMU_BLKIO_ASSIGN(rbps, "%llu", VIR_DOMAIN_BLKIO_DEVICE_READ_BPS);
|
|
||||||
/* blkiotune.device_write_bps */
|
|
||||||
QEMU_BLKIO_ASSIGN(wbps, "%llu", VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS);
|
|
||||||
|
|
||||||
#undef QEMU_BLKIO_ASSIGN
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(data);
|
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetBlkioParameters(virDomainPtr dom,
|
qemuDomainGetBlkioParameters(virDomainPtr dom,
|
||||||
virTypedParameterPtr params,
|
virTypedParameterPtr params,
|
||||||
@ -9220,8 +9169,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
|||||||
VIR_TYPED_PARAM_UINT, val) < 0)
|
VIR_TYPED_PARAM_UINT, val) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainGetBlkioParametersAssignFromDef(def, params, nparams,
|
if (virDomainGetBlkioParametersAssignFromDef(def, params, nparams,
|
||||||
maxparams) < 0)
|
maxparams) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
} else if (persistentDef) {
|
} else if (persistentDef) {
|
||||||
@ -9232,8 +9181,8 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
|||||||
persistentDef->blkio.weight) < 0)
|
persistentDef->blkio.weight) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainGetBlkioParametersAssignFromDef(persistentDef, params,
|
if (virDomainGetBlkioParametersAssignFromDef(persistentDef, params,
|
||||||
nparams, maxparams) < 0)
|
nparams, maxparams) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user