[libvirt] [PATCH] storage: Fix build due to recent storage backend code movement
by John Ferlan
Commit id '5f07c3c07' broke the freebsd build in the libvirt CI test
environment because the UMOUNT was not defined unless WITH_STORAGE_FS
is defined.
So remove the virStorageBackendUmountLocal from storage_util.c,h and
restore the code back in the storage_backend_fs.c and _vstorage.c
modules.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
This is a build breaker - I'll push shortly...
src/storage/storage_backend_fs.c | 11 ++++++++++-
src/storage/storage_backend_vstorage.c | 11 ++++++++++-
src/storage/storage_util.c | 18 ------------------
src/storage/storage_util.h | 2 --
4 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 9710648..54bcc57 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -452,6 +452,8 @@ static int
virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool)
{
+ virCommandPtr cmd = NULL;
+ int ret = -1;
int rc;
if (virStorageBackendFileSystemIsValid(pool) < 0)
@@ -461,7 +463,14 @@ virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
if ((rc = virStorageBackendFileSystemIsMounted(pool)) != 1)
return rc;
- return virStorageBackendUmountLocal(pool);
+ cmd = virCommandNewArgList(UMOUNT, pool->def->target.path, NULL);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virCommandFree(cmd);
+ return ret;
}
#endif /* WITH_STORAGE_FS */
diff --git a/src/storage/storage_backend_vstorage.c b/src/storage/storage_backend_vstorage.c
index d3a12fb..0e945af 100644
--- a/src/storage/storage_backend_vstorage.c
+++ b/src/storage/storage_backend_vstorage.c
@@ -125,13 +125,22 @@ static int
virStorageBackendVzPoolStop(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool)
{
+ virCommandPtr cmd = NULL;
+ int ret = -1;
int rc;
/* Short-circuit if already unmounted */
if ((rc = virStorageBackendVzIsMounted(pool)) != 1)
return rc;
- return virStorageBackendUnmountLocal(pool);
+ cmd = virCommandNewArgList(UMOUNT, pool->def->target.path, NULL);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ virCommandFree(cmd);
+ return ret;
}
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index fbe1844..a665bac 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -2803,24 +2803,6 @@ virStorageBackendBuildLocal(virStoragePoolObjPtr pool)
}
-int
-virStorageBackendUmountLocal(virStoragePoolObjPtr pool)
-{
- int ret = -1;
- virCommandPtr cmd = virCommandNewArgList(UMOUNT, pool->def->target.path,
- NULL);
-
- if (virCommandRun(cmd, NULL) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
- virCommandFree(cmd);
- return ret;
-}
-
-
/**
* @conn connection to report errors against
* @pool storage pool to delete
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index 49df530..326d555 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -87,8 +87,6 @@ int virStorageBackendVolWipeLocal(virConnectPtr conn,
/* Local/Common Storage Pool Backend APIs */
int virStorageBackendBuildLocal(virStoragePoolObjPtr pool);
-int virStorageBackendUmountLocal(virStoragePoolObjPtr pool);
-
int virStorageBackendDeleteLocal(virConnectPtr conn,
virStoragePoolObjPtr pool,
unsigned int flags);
--
2.7.4
7 years, 10 months
[libvirt] [PATCH 0/3] Move FS Storage Backend API's to storage_util
by John Ferlan
While reviewing the Virtuozzo backend changes it became apparent that
my initial review comments weren't fully understood. Rather than going
back and forth more on this, I figured I'd take the plunge and make the
"preparations". Also since the storage_util is the new dumping ground,
I went there. It also already has the API's for the storage backend
upload, download, and wipe - so these patches add a few more from the
pool class and the rest of the volume class.
FWIW: Rather than just making and bundling the changes with the Virtuozzo
changes, I figured I'd post them separately just in case someone has agita
over the API/helper name changes.
John Ferlan (3):
storage: Move the virStorageBackendFileSystem{Start|Stop} API's
storage: Create common file/dir pool backend helpers
storage: Create common file/dir volume backend helpers
src/storage/storage_backend.c | 1 +
src/storage/storage_backend_fs.c | 827 +++-------------------------------
src/storage/storage_util.c | 931 ++++++++++++++++++++++++++++++++++-----
src/storage/storage_util.h | 79 ++--
4 files changed, 924 insertions(+), 914 deletions(-)
--
2.7.4
7 years, 10 months
[libvirt] [PATCH 0/4] Support setting MTU on domain interfaces
by Michal Privoznik
After Laine merges his patches [1] the only missing piece is setting MTU on a
domain <interface/>. Well, up until now :-)
1: https://www.redhat.com/archives/libvir-list/2017-January/msg00946.html
Michal Privoznik (4):
formatnetwork.html.in: Fix #elementsNICS anchor
virDomainNetDefParseXML: s/ret/rv/
domain_conf: Introduce <mtu/> to <interface/>
qemu: Implement mtu on interface
docs/formatdomain.html.in | 19 ++++++
docs/formatnetwork.html.in | 4 +-
docs/schemas/domaincommon.rng | 3 +
docs/schemas/networkcommon.rng | 9 +++
src/conf/domain_conf.c | 18 ++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 14 +++++
src/qemu/qemu_domain.c | 30 ++++++++++
src/qemu/qemu_domain.h | 2 +
tests/qemuxml2argvdata/qemuxml2argv-net-mtu.xml | 60 +++++++++++++++++++
.../qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml | 68 ++++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
14 files changed, 226 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-mtu.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-mtu.xml
--
2.11.0
7 years, 10 months
[libvirt] [PATCHv2 1/3] util: unlock closeCallbacks if get callbacks for connect fail
by Wang King
Avoid return with the closeCallbacks locked when get callbacks list for connect fail.
Signed-off-by: Wang King <king.wang(a)huawei.com>
---
src/util/virclosecallbacks.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virclosecallbacks.c b/src/util/virclosecallbacks.c
index 891a92b..1fa9596 100644
--- a/src/util/virclosecallbacks.c
+++ b/src/util/virclosecallbacks.c
@@ -331,8 +331,10 @@ virCloseCallbacksRun(virCloseCallbacksPtr closeCallbacks,
virObjectLock(closeCallbacks);
list = virCloseCallbacksGetForConn(closeCallbacks, conn);
- if (!list)
+ if (!list) {
+ virObjectLock(closeCallbacks);
return;
+ }
for (i = 0; i < list->nentries; i++) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
--
2.8.3
7 years, 10 months
[libvirt] non-standard types in remote XDR definitions
by Matt Broadstone
Hello,
I have been experimenting with the remote protocol defined in the
`src/remote/remote_protocol.x`
(https://libvirt.org/git/?p=libvirt.git;a=blob_plain;f=src/remote/remote_p...),
and noticed that there a number of types used that are not defined in
the XDR RFC, specifically: unsigned char, char, unsigned short, short
(I might have missed one or two). I'm wondering if these are missing
typedefs, or whether they are custom extensions to the RFC. Does
anyone have more information on this? If the latter case is the fact,
are these values padded to 4 bytes per the spec?
Thanks,
Matt
7 years, 10 months
[libvirt] [PATCH] perf: introduce option --reset
by Nitesh Konkar
Currently you can either enable or disable a
perf event. This patch allows you to reset the
perf event using command line option --reset.
Eg: virsh perf domainName --reset cpu_cycles
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
Example:
virsh domstats Fedora --perf
Domain: 'Fedora'
virsh perf Fedora --enable cpu_cycles,cache_references
cpu_cycles : enabled
cache_references: enabled
virsh domstats Fedora --perf
Domain: 'Fedora'
perf.cpu_cycles=107559185
perf.cache_references=563288
virsh perf Fedora --reset cache_misses,cpu_cycles,cache_references
cache_misses : reset
cpu_cycles : reset
cache_references: reset
virsh domstats Fedora --perf
Domain: 'Fedora'
perf.cpu_cycles=0
perf.cache_references=0
perf.cache_misses=0
virsh perf Fedora --reset cache_misses,cpu_cycles,cache_references --config
error: Options --reset and --config are mutually exclusive
Should reset option be made available in the domainxml along with
enabled=yes/no ? I have not included any such change in this patch as
I think that there is no need to reset a perf counter as its value
for the VM's pid shall start by default at zero unless enabled.
include/libvirt/libvirt-domain.h | 6 +++++
src/libvirt_private.syms | 1 +
src/qemu/qemu_driver.c | 52 ++++++++++++++++++++--------------------
src/qemu/qemu_process.c | 22 +++++++++++++----
src/util/virperf.c | 52 ++++++++++++++++++++++++++++------------
src/util/virperf.h | 12 ++++++----
tools/virsh-domain.c | 37 ++++++++++++++++++----------
7 files changed, 120 insertions(+), 62 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index e303140..6072f00 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -2188,6 +2188,12 @@ void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
*/
# define VIR_PERF_PARAM_REF_CPU_CYCLES "ref_cpu_cycles"
+enum {
+VIR_PERF_STATE_DISABLED,
+VIR_PERF_STATE_ENABLED,
+VIR_PERF_STATE_RESET,
+};
+
int virDomainGetPerfEvents(virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cfeb43c..61bd207 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2229,6 +2229,7 @@ virPCIStubDriverTypeToString;
virPerfEventDisable;
virPerfEventEnable;
virPerfEventIsEnabled;
+virPerfEventSetFd;
virPerfEventTypeFromString;
virPerfEventTypeToString;
virPerfFree;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 516a851..8dd3ab7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9530,25 +9530,25 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
virDomainDefPtr persistentDef;
int ret = -1;
virPerfEventType type;
- bool enabled;
+ int state;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
if (virTypedParamsValidate(params, nparams,
- VIR_PERF_PARAM_CMT, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_MBMT, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_MBML, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_CPU_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_INSTRUCTIONS, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_CACHE_REFERENCES, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_CACHE_MISSES, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_BRANCH_INSTRUCTIONS, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_BRANCH_MISSES, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_BUS_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_STALLED_CYCLES_FRONTEND, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_STALLED_CYCLES_BACKEND, VIR_TYPED_PARAM_BOOLEAN,
- VIR_PERF_PARAM_REF_CPU_CYCLES, VIR_TYPED_PARAM_BOOLEAN,
+ VIR_PERF_PARAM_CMT, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_MBMT, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_MBML, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_CPU_CYCLES, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_INSTRUCTIONS, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_CACHE_REFERENCES, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_CACHE_MISSES, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_BRANCH_INSTRUCTIONS, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_BRANCH_MISSES, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_BUS_CYCLES, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_STALLED_CYCLES_FRONTEND, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_STALLED_CYCLES_BACKEND, VIR_TYPED_PARAM_INT,
+ VIR_PERF_PARAM_REF_CPU_CYCLES, VIR_TYPED_PARAM_INT,
NULL) < 0)
return -1;
@@ -9570,16 +9570,17 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
if (def) {
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
- enabled = param->value.b;
+ state = param->value.i;
type = virPerfEventTypeFromString(param->field);
- if (!enabled && virPerfEventDisable(priv->perf, type) < 0)
- goto endjob;
- if (enabled && virPerfEventEnable(priv->perf, type, vm->pid) < 0)
+ if ((state == VIR_PERF_STATE_DISABLED) && virPerfEventDisable(priv->perf, type) < 0) {
goto endjob;
+ } else {
+ if (virPerfEventSetFd(priv->perf, type, vm->pid, state) < 0)
+ goto endjob;
+ }
- def->perf.events[type] = enabled ?
- VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
+ def->perf.events[type] = state;
}
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
@@ -9589,11 +9590,10 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
if (persistentDef) {
for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = ¶ms[i];
- enabled = param->value.b;
+ state = param->value.i;
type = virPerfEventTypeFromString(param->field);
- persistentDef->perf.events[type] = enabled ?
- VIR_TRISTATE_BOOL_YES : VIR_TRISTATE_BOOL_NO;
+ persistentDef->perf.events[type] = state;
}
if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0)
@@ -9649,14 +9649,14 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
priv = vm->privateData;
for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
- bool perf_enabled;
+ int perf_enabled;
if (flags & VIR_DOMAIN_AFFECT_CONFIG)
- perf_enabled = def->perf.events[i] == VIR_TRISTATE_BOOL_YES;
+ perf_enabled = def->perf.events[i];
else
perf_enabled = virPerfEventIsEnabled(priv->perf, i);
- if (virTypedParamsAddBoolean(&par, &npar, &maxpar,
+ if (virTypedParamsAddInt(&par, &npar, &maxpar,
virPerfEventTypeToString(i),
perf_enabled) < 0)
goto endjob;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 184440d..1bd7979 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3200,11 +3200,19 @@ qemuDomainPerfRestart(virDomainObjPtr vm)
for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
if (def->perf.events[i] &&
- def->perf.events[i] == VIR_TRISTATE_BOOL_YES) {
+ def->perf.events[i] == VIR_PERF_STATE_ENABLED) {
/* Failure to re-enable the perf event should not be fatal */
- if (virPerfEventEnable(priv->perf, i, vm->pid) < 0)
- def->perf.events[i] = VIR_TRISTATE_BOOL_NO;
+ if (virPerfEventSetFd(priv->perf, i, vm->pid, VIR_PERF_STATE_ENABLED) < 0)
+ def->perf.events[i] = VIR_PERF_STATE_DISABLED;
+ }
+
+ if (def->perf.events[i] &&
+ def->perf.events[i] == VIR_PERF_STATE_RESET) {
+
+ /* Failure to reset the perf event should not be fatal */
+ if (virPerfEventSetFd(priv->perf, i, vm->pid, VIR_PERF_STATE_RESET) < 0)
+ def->perf.events[i] = VIR_PERF_STATE_DISABLED;
}
}
@@ -5563,8 +5571,12 @@ qemuProcessLaunch(virConnectPtr conn,
goto cleanup;
for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
- if (vm->def->perf.events[i] == VIR_TRISTATE_BOOL_YES &&
- virPerfEventEnable(priv->perf, i, vm->pid) < 0)
+ if (vm->def->perf.events[i] == VIR_PERF_STATE_ENABLED &&
+ virPerfEventSetFd(priv->perf, i, vm->pid, VIR_PERF_STATE_ENABLED) < 0)
+ goto cleanup;
+
+ if (vm->def->perf.events[i] == VIR_PERF_STATE_RESET &&
+ virPerfEventSetFd(priv->perf, i, vm->pid, VIR_PERF_STATE_RESET) < 0)
goto cleanup;
}
diff --git a/src/util/virperf.c b/src/util/virperf.c
index f64692b..125166b 100644
--- a/src/util/virperf.c
+++ b/src/util/virperf.c
@@ -48,7 +48,7 @@ VIR_ENUM_IMPL(virPerfEvent, VIR_PERF_EVENT_LAST,
struct virPerfEvent {
int type;
int fd;
- bool enabled;
+ int state;
union {
/* cmt */
struct {
@@ -186,9 +186,25 @@ virPerfGetEvent(virPerfPtr perf,
}
int
-virPerfEventEnable(virPerfPtr perf,
+virPerfEventEnable(int fd)
+{
+ if (ioctl(fd, PERF_EVENT_IOC_ENABLE) < 0)
+ return -1;
+ return 0;
+}
+
+int
+virPerfEventReset(int fd)
+{
+ if (ioctl(fd, PERF_EVENT_IOC_RESET) < 0)
+ return -1;
+ return 0;
+}
+
+int
+virPerfEventSetFd(virPerfPtr perf,
virPerfEventType type,
- pid_t pid)
+ pid_t pid, int state)
{
char *buf = NULL;
struct perf_event_attr attr;
@@ -237,14 +253,20 @@ virPerfEventEnable(virPerfPtr perf,
goto error;
}
- if (ioctl(event->fd, PERF_EVENT_IOC_ENABLE) < 0) {
+ if (state == VIR_PERF_STATE_ENABLED && virPerfEventEnable(event->fd) < 0) {
virReportSystemError(errno,
_("unable to enable host cpu perf event for %s"),
virPerfEventTypeToString(event->type));
goto error;
}
- event->enabled = true;
+ if (state == VIR_PERF_STATE_RESET && virPerfEventReset(event->fd) < 0) {
+ virReportSystemError(errno,
+ _("unable to reset host cpu perf event for %s"),
+ virPerfEventTypeToString(event->type));
+ goto error;
+ }
+ event->state = state;
return 0;
error:
@@ -261,7 +283,7 @@ virPerfEventDisable(virPerfPtr perf,
if (event == NULL)
return -1;
- if (!event->enabled)
+ if (!event->state)
return 0;
if (ioctl(event->fd, PERF_EVENT_IOC_DISABLE) < 0) {
@@ -271,19 +293,19 @@ virPerfEventDisable(virPerfPtr perf,
return -1;
}
- event->enabled = false;
+ event->state = VIR_PERF_STATE_DISABLED;
VIR_FORCE_CLOSE(event->fd);
return 0;
}
-bool virPerfEventIsEnabled(virPerfPtr perf,
+int virPerfEventIsEnabled(virPerfPtr perf,
virPerfEventType type)
{
virPerfEventPtr event = virPerfGetEvent(perf, type);
if (event == NULL)
return false;
- return event->enabled;
+ return event->state;
}
int
@@ -292,7 +314,7 @@ virPerfReadEvent(virPerfPtr perf,
uint64_t *value)
{
virPerfEventPtr event = virPerfGetEvent(perf, type);
- if (event == NULL || !event->enabled)
+ if (event == NULL || !event->state)
return -1;
if (saferead(event->fd, value, sizeof(uint64_t)) < 0) {
@@ -316,7 +338,7 @@ virPerfRdtAttrInit(void)
int
-virPerfEventEnable(virPerfPtr perf ATTRIBUTE_UNUSED,
+virPerfEventSetFd(virPerfPtr perf ATTRIBUTE_UNUSED,
virPerfEventType type ATTRIBUTE_UNUSED,
pid_t pid ATTRIBUTE_UNUSED)
{
@@ -334,11 +356,11 @@ virPerfEventDisable(virPerfPtr perf ATTRIBUTE_UNUSED,
return -1;
}
-bool
+int
virPerfEventIsEnabled(virPerfPtr perf ATTRIBUTE_UNUSED,
virPerfEventType type ATTRIBUTE_UNUSED)
{
- return false;
+ return 0;
}
int
@@ -365,7 +387,7 @@ virPerfNew(void)
for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
perf->events[i].type = i;
perf->events[i].fd = -1;
- perf->events[i].enabled = false;
+ perf->events[i].state = VIR_PERF_STATE_DISABLED;
}
if (virPerfRdtAttrInit() < 0)
@@ -383,7 +405,7 @@ virPerfFree(virPerfPtr perf)
return;
for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
- if (perf->events[i].enabled)
+ if (perf->events[i].state >= VIR_PERF_STATE_ENABLED)
virPerfEventDisable(perf, i);
}
diff --git a/src/util/virperf.h b/src/util/virperf.h
index 1f43c92..f79ef31 100644
--- a/src/util/virperf.h
+++ b/src/util/virperf.h
@@ -60,14 +60,18 @@ virPerfPtr virPerfNew(void);
void virPerfFree(virPerfPtr perf);
-int virPerfEventEnable(virPerfPtr perf,
- virPerfEventType type,
- pid_t pid);
+int virPerfEventSetFd(virPerfPtr perf,
+ virPerfEventType type,
+ pid_t pid, int state);
+
+int virPerfEventEnable(int fd);
+
+int virPerfEventReset(int fd);
int virPerfEventDisable(virPerfPtr perf,
virPerfEventType type);
-bool virPerfEventIsEnabled(virPerfPtr perf,
+int virPerfEventIsEnabled(virPerfPtr perf,
virPerfEventType type);
int virPerfReadEvent(virPerfPtr perf,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 93587e8..806490b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8794,7 +8794,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
*/
static const vshCmdInfo info_perf[] = {
{.name = "help",
- .data = N_("Get or set perf event")
+ .data = N_("Get, set or reset perf event")
},
{.name = "desc",
.data = N_("Get or set the current perf events for a guest"
@@ -8815,6 +8815,10 @@ static const vshCmdOptDef opts_perf[] = {
.type = VSH_OT_STRING,
.help = N_("perf events which will be disabled")
},
+ {.name = "reset",
+ .type = VSH_OT_STRING,
+ .help = N_("perf events which will be reset")
+ },
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
VIRSH_COMMON_OPT_DOMAIN_LIVE,
VIRSH_COMMON_OPT_DOMAIN_CURRENT,
@@ -8823,7 +8827,7 @@ static const vshCmdOptDef opts_perf[] = {
static int
virshParseEventStr(const char *event,
- bool state,
+ int state,
virTypedParameterPtr *params,
int *nparams,
int *maxparams)
@@ -8837,7 +8841,7 @@ virshParseEventStr(const char *event,
for (i = 0; i < ntok; i++) {
if ((*tok[i] != '\0') &&
- virTypedParamsAddBoolean(params, nparams,
+ virTypedParamsAddInt(params, nparams,
maxparams, tok[i], state) < 0)
goto cleanup;
}
@@ -8854,9 +8858,11 @@ virshPrintPerfStatus(vshControl *ctl, virTypedParameterPtr params, int nparams)
size_t i;
for (i = 0; i < nparams; i++) {
- if (params[i].type == VIR_TYPED_PARAM_BOOLEAN &&
- params[i].value.b) {
+ if (params[i].type == VIR_TYPED_PARAM_INT &&
+ params[i].value.i == VIR_PERF_STATE_ENABLED) {
vshPrintExtra(ctl, "%-15s: %s\n", params[i].field, _("enabled"));
+ } else if (params[i].value.i == VIR_PERF_STATE_RESET) {
+ vshPrintExtra(ctl, "%-15s: %s\n", params[i].field, _("reset"));
} else {
vshPrintExtra(ctl, "%-15s: %s\n", params[i].field, _("disabled"));
}
@@ -8871,14 +8877,16 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
int maxparams = 0;
virTypedParameterPtr params = NULL;
bool ret = false;
- const char *enable = NULL, *disable = NULL;
+ const char *enable = NULL, *disable = NULL, *resett = NULL;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
+ bool reset = vshCommandOptBool(cmd, "reset");
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+ VSH_EXCLUSIVE_OPTIONS_VAR(reset, config);
if (config)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
@@ -8886,18 +8894,23 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (vshCommandOptStringReq(ctl, cmd, "enable", &enable) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0)
+ vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "reset", &resett) < 0)
return false;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (enable && virshParseEventStr(enable, true, ¶ms,
- &nparams, &maxparams) < 0)
+ if (enable && virshParseEventStr(enable, VIR_PERF_STATE_ENABLED,
+ ¶ms, &nparams, &maxparams) < 0)
+ goto cleanup;
+
+ if (disable && virshParseEventStr(disable, VIR_PERF_STATE_DISABLED,
+ ¶ms, &nparams, &maxparams) < 0)
goto cleanup;
- if (disable && virshParseEventStr(disable, false, ¶ms,
- &nparams, &maxparams) < 0)
+ if (resett && virshParseEventStr(resett, VIR_PERF_STATE_RESET,
+ ¶ms, &nparams, &maxparams) < 0)
goto cleanup;
if (nparams == 0) {
@@ -8908,7 +8921,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
virshPrintPerfStatus(ctl, params, nparams);
} else {
if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0) {
- vshError(ctl, "%s", _("Unable to enable/disable perf events"));
+ vshError(ctl, "%s", _("Unable to enable/disable/reset perf events"));
goto cleanup;
} else {
virshPrintPerfStatus(ctl, params, nparams);
--
1.9.3
7 years, 10 months
[libvirt] [PATCH 0/2] *** Expose host's cache information in capabilities ***
by Eli Qiao
This series patches are the first step to support CAT featues, which also
called cache tune in libvirt.
First to expose cache information which could be tuned in capabilites XML,
later will add some more interface to do cache tune.
Some discussion about this feature support can be found from:
https://www.redhat.com/archives/libvir-list/2017-January/msg00644.html
Eli Qiao (2):
Resctrl: Add some utils functions
Resctrl: expose cache information to capabilities
include/libvirt/virterror.h | 1 +
src/Makefile.am | 1 +
src/conf/capabilities.c | 30 +++
src/conf/capabilities.h | 15 ++
src/libvirt_private.syms | 5 +
src/qemu/qemu_capabilities.c | 42 ++++
src/qemu/qemu_driver.c | 4 +
src/util/virerror.c | 1 +
src/util/virresctrl.c | 500 +++++++++++++++++++++++++++++++++++++++++++
src/util/virresctrl.h | 121 +++++++++++
tests/Makefile.am | 4 +
11 files changed, 724 insertions(+)
create mode 100644 src/util/virresctrl.c
create mode 100644 src/util/virresctrl.h
--
1.9.1
7 years, 10 months
[libvirt] [PATCH v2] network: make openvswitch call timeout compile time configurable
by Boris Fiuczynski
Since a successful completion of the calls to openvswitch is expected
a long timeout should be chosen to account for heavily loaded systems.
Therefore this patch increases the timeout value from 5 to 120 seconds
as default value and also allows to set the openvswitch timeout value
by specifying with-ovs-timeout when running configure.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
---
configure.ac | 3 +++
m4/virt-ovs-timeout.m4 | 34 ++++++++++++++++++++++++++++++++++
src/util/virnetdevopenvswitch.c | 9 +++++----
3 files changed, 42 insertions(+), 4 deletions(-)
create mode 100644 m4/virt-ovs-timeout.m4
diff --git a/configure.ac b/configure.ac
index 7efaddb..e70dfdc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -463,6 +463,7 @@ LIBVIRT_ARG_LOADER_NVRAM
LIBVIRT_ARG_LOGIN_SHELL
LIBVIRT_ARG_HOST_VALIDATE
LIBVIRT_ARG_TLS_PRIORITY
+LIBVIRT_ARG_OVS_TIMEOUT
LIBVIRT_ARG_SYSCTL_CONFIG
@@ -477,6 +478,7 @@ LIBVIRT_CHECK_LOADER_NVRAM
LIBVIRT_CHECK_LOGIN_SHELL
LIBVIRT_CHECK_HOST_VALIDATE
LIBVIRT_CHECK_TLS_PRIORITY
+LIBVIRT_CHECK_OVS_TIMEOUT
LIBVIRT_CHECK_SYSCTL_CONFIG
LIBVIRT_CHECK_NSS
@@ -1012,6 +1014,7 @@ LIBVIRT_RESULT_LOADER_NVRAM
LIBVIRT_RESULT_LOGIN_SHELL
LIBVIRT_RESULT_HOST_VALIDATE
LIBVIRT_RESULT_TLS_PRIORITY
+LIBVIRT_RESULT_OVS_TIMEOUT
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Developer Tools])
AC_MSG_NOTICE([])
diff --git a/m4/virt-ovs-timeout.m4 b/m4/virt-ovs-timeout.m4
new file mode 100644
index 0000000..a5174d5
--- /dev/null
+++ b/m4/virt-ovs-timeout.m4
@@ -0,0 +1,34 @@
+dnl The OVS timeout check
+dnl
+dnl Copyright (C) 2017 IBM Corporation
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([LIBVIRT_ARG_OVS_TIMEOUT], [
+ LIBVIRT_ARG_WITH([OVS_TIMEOUT],
+ [set the default OVS timeout],
+ 120)
+])
+
+AC_DEFUN([LIBVIRT_CHECK_OVS_TIMEOUT], [
+ AC_DEFINE_UNQUOTED([OVS_TIMEOUT], ["$with_ovs_timeout"],
+ [default OVS timeout])
+])
+
+AC_DEFUN([LIBVIRT_RESULT_OVS_TIMEOUT], [
+dnl AC_MSG_NOTICE([OVS timeout: $with_ovs_timeout])
+ LIBVIRT_RESULT([ OVS timeout], [$with_ovs_timeout])
+])
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index e6cb096..ba44b3b 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -35,6 +35,7 @@
#include "virlog.h"
#define VIR_FROM_THIS VIR_FROM_NONE
+#define OVS_TIMEOUT_ARG "--timeout=" OVS_TIMEOUT
VIR_LOG_INIT("util.netdevopenvswitch");
@@ -89,7 +90,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
cmd = virCommandNew(OVSVSCTL);
- virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port",
+ virCommandAddArgList(cmd, OVS_TIMEOUT_ARG, "--", "--if-exists", "del-port",
ifname, "--", "add-port", brname, ifname, NULL);
if (virtVlan && virtVlan->nTags > 0) {
@@ -183,7 +184,7 @@ int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const ch
virCommandPtr cmd = NULL;
cmd = virCommandNew(OVSVSCTL);
- virCommandAddArgList(cmd, "--timeout=5", "--", "--if-exists", "del-port", ifname, NULL);
+ virCommandAddArgList(cmd, OVS_TIMEOUT_ARG, "--", "--if-exists", "del-port", ifname, NULL);
if (virCommandRun(cmd, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -212,7 +213,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
size_t len;
int ret = -1;
- cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5", "--if-exists", "get", "Interface",
+ cmd = virCommandNewArgList(OVSVSCTL, OVS_TIMEOUT_ARG, "--if-exists", "get", "Interface",
ifname, "external_ids:PortData", NULL);
virCommandSetOutputBuffer(cmd, migrate);
@@ -255,7 +256,7 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname)
return 0;
}
- cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5", "set",
+ cmd = virCommandNewArgList(OVSVSCTL, OVS_TIMEOUT_ARG, "set",
"Interface", ifname, NULL);
virCommandAddArgFormat(cmd, "external_ids:PortData=%s", migrate);
--
2.5.5
7 years, 10 months
[libvirt] [PATCH] configure: fix indentation in TLS priority result
by Boris Fiuczynski
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
m4/virt-tls-priority.m4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/m4/virt-tls-priority.m4 b/m4/virt-tls-priority.m4
index f7a6c56..44d9f68 100644
--- a/m4/virt-tls-priority.m4
+++ b/m4/virt-tls-priority.m4
@@ -29,5 +29,5 @@ AC_DEFUN([LIBVIRT_CHECK_TLS_PRIORITY], [
])
AC_DEFUN([LIBVIRT_RESULT_TLS_PRIORITY], [
- LIBVIRT_RESULT([TLS priority], [$with_tls_priority])
+ LIBVIRT_RESULT([ TLS priority], [$with_tls_priority])
])
--
2.5.5
7 years, 10 months
[libvirt] [PATCH] THREADS.txt: fix typos
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
s/wakup/wakeup
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
daemon/THREADS.txt | 2 +-
src/util/vireventpoll.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon/THREADS.txt b/daemon/THREADS.txt
index 762ca25..ae4e9ba 100644
--- a/daemon/THREADS.txt
+++ b/daemon/THREADS.txt
@@ -42,7 +42,7 @@ event loop thread handles I/O from the client socket, and once a
complete RPC message has been read off the wire (and optionally
decrypted), it will be placed on the 'dx' job queue for the
associated client object. The job condition will be signalled and
-a worker will wakup and process it.
+a worker will wakeup and process it.
The worker thread must quickly drop its locks on the server and
client to allow the main event loop thread to continue running
diff --git a/src/util/vireventpoll.h b/src/util/vireventpoll.h
index 8844c9c..e78e273 100644
--- a/src/util/vireventpoll.h
+++ b/src/util/vireventpoll.h
@@ -124,7 +124,7 @@ int virEventPollToNativeEvents(int events);
/**
* virEventPollInterrupt: wakeup any thread waiting in poll()
*
- * return -1 if wakup failed
+ * return -1 if wakeup failed
*/
int virEventPollInterrupt(void);
--
2.7.4
7 years, 10 months