[libvirt] [PATCH] qemu: blockCopy: Pass adjusted bandwidth when called via blockRebase
by Peter Krempa
The block copy API takes the speed in bytes/s rather than MiB/s that was
the prior approach in virDomainBlockRebase. We correctly converted the
speed to bytes/s in the old API but we still called the common helper
virDomainBlockCopyCommon with the unadjusted variable.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207122
---
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4d05221..6700fc9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16811,7 +16811,7 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
flags &= (VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT);
ret = qemuDomainBlockCopyCommon(vm, dom->conn, path, dest,
- bandwidth, 0, 0, flags, true);
+ speed, 0, 0, flags, true);
dest = NULL;
cleanup:
--
2.2.2
9 years, 8 months
[libvirt] [PATCH 0/6] Few NUMA fixes
by Michal Privoznik
The heart of the patchset are the last two patches. Long story
short, if a domain is configured to be pinned onto a set of NUMA
nodes stricly, we use both CGroups and numa_set_membind(). While
we can change the former later on a user's wish, we can't change
the latter. Therefore, any subsequent memory enlargement (e.g.
via virsh setmem $dom) will result in memory still being
allocated from old NUMA nodes and OOM killer interference is
likely to occur.
Michal Privoznik (6):
virCgroupNewPartition: Fix comment
virCgroupNew: Enhance debug message
virCgroupController: Check the enum fits into 'int'
qemuDomainGetNumaParameters: Check for the correct CGroup controller
qemuProcessHook: Call virNuma*() iff needed
virLXCControllerSetupResourceLimits: Call virNuma*() iff needed
src/lxc/lxc_controller.c | 31 +++++++++++++++++++++++++------
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_process.c | 32 ++++++++++++++++++++++++++++----
src/util/vircgroup.c | 6 +++---
src/util/vircgroup.h | 5 +++++
5 files changed, 62 insertions(+), 14 deletions(-)
--
2.0.5
9 years, 8 months
[libvirt] [PATCH] interface: allow multiple IPv4 addresses in interface XML
by Laine Stump
An upcoming netcf release will support multiple ipv4 addresses, so
let's loosen up libvirt's interface.rng to allow it.
---
docs/schemas/interface.rng | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng
index bf0346c..45b40cd 100644
--- a/docs/schemas/interface.rng
+++ b/docs/schemas/interface.rng
@@ -326,12 +326,14 @@
<choice>
<ref name="dhcp-element"/>
<group>
- <element name="ip">
- <attribute name="address"><ref name="ipv4Addr"/></attribute>
- <optional>
- <attribute name="prefix"><ref name="ipv4Prefix"/></attribute>
- </optional>
- </element>
+ <oneOrMore>
+ <element name="ip">
+ <attribute name="address"><ref name="ipv4Addr"/></attribute>
+ <optional>
+ <attribute name="prefix"><ref name="ipv4Prefix"/></attribute>
+ </optional>
+ </element>
+ </oneOrMore>
<optional>
<element name="route">
<attribute name="gateway"><ref name="ipv4Addr"/></attribute>
--
2.1.0
9 years, 8 months
[libvirt] ceph rbd key
by Raymond Durand
Is there a way that qemu takes the key of ceph rbd from a file rather than
reading it from the file cinder.conf?
Going from something like rbd_secret_uuid=UUID key
to something like rbd_secret_uuid=/path/to/key
(to restrict the access rights to the file and avoid the secret_uuid to be
readable from anyone with ps kind of command)
Regards,
9 years, 8 months
[libvirt] [RFC] Add uptime to API returning Dom Info
by Nehal J Wani
This is an attempt to fix: https://bugzilla.redhat.com/show_bug.cgi?id=812911
Calculate vm uptime by subtracting process starttime from system uptime:
Almost equivalent to:
echo $(($(($(awk '{print $1}' /proc/uptime)*1e9 - $(($(cut -d " " -f22 /proc/$PID/stat)*1e7))))/(1.0 * 1e9)))
---
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_driver.c | 32 +++++++++++++++++++++++++-------
src/remote/remote_protocol.x | 1 +
src/remote_protocol-structs | 1 +
tools/virsh-domain-monitor.c | 8 ++++++++
5 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7be4219..2df0241 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -275,6 +275,7 @@ struct _virDomainInfo {
unsigned long memory; /* the memory in KBytes used by the domain */
unsigned short nrVirtCpu; /* the number of virtual CPUs for the domain */
unsigned long long cpuTime; /* the CPU time used in nanoseconds */
+ unsigned long long upTime; /* the total uptime in nanoseconds */
};
/**
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f07e4fb..0b5098f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1309,11 +1309,12 @@ static char *qemuConnectGetCapabilities(virConnectPtr conn) {
static int
qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
- pid_t pid, int tid)
+ pid_t pid, int tid, unsigned long long *upTime)
{
char *proc;
FILE *pidinfo;
- unsigned long long usertime = 0, systime = 0;
+ unsigned long long usertime = 0, systime = 0, starttime = 0;
+ double _uptime;
long rss = 0;
int cpu = 0;
int ret;
@@ -1337,13 +1338,29 @@ qemuGetProcessInfo(unsigned long long *cpuTime, int *lastCpu, long *vm_rss,
/* pid -> stime */
"%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu"
/* cutime -> endcode */
- "%*d %*d %*d %*d %*d %*d %*u %*u %ld %*u %*u %*u"
+ "%*d %*d %*d %*d %*d %*d %llu %*u %ld %*u %*u %*u"
/* startstack -> processor */
"%*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %d",
- &usertime, &systime, &rss, &cpu) != 4) {
+ &usertime, &systime, &starttime, &rss, &cpu) != 5) {
VIR_WARN("cannot parse process status data");
}
+ ret = virAsprintf(&proc, "/proc/uptime");
+ if (ret < 0)
+ return -1;
+
+ pidinfo = fopen(proc, "r");
+ VIR_FREE(proc);
+
+ if (!pidinfo || fscanf(pidinfo, "%lf %*f", &_uptime) != 1) {
+ VIR_WARN("cannot parse machine uptime data");
+ }
+
+ if (upTime)
+ *upTime = 1000ull * 1000ull * 1000ull * _uptime -
+ (1000ull * 1000ull * 1000ull * starttime)
+ / (unsigned long long)sysconf(_SC_CLK_TCK);
+
/* We got jiffies
* We want nanoseconds
* _SC_CLK_TCK is jiffies per second
@@ -1404,7 +1421,8 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, virVcpuInfoPtr info, int maxinfo,
&(info[i].cpu),
NULL,
vm->pid,
- priv->vcpupids[i]) < 0) {
+ priv->vcpupids[i],
+ NULL) < 0) {
virReportSystemError(errno, "%s",
_("cannot get vCPU placement & pCPU time"));
return -1;
@@ -2595,7 +2613,7 @@ static int qemuDomainGetInfo(virDomainPtr dom,
if (!virDomainObjIsActive(vm)) {
info->cpuTime = 0;
} else {
- if (qemuGetProcessInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0) < 0) {
+ if (qemuGetProcessInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0, &(info->upTime)) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot read cputime for domain"));
goto cleanup;
@@ -11474,7 +11492,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
if (ret >= 0 && ret < nr_stats) {
long rss;
- if (qemuGetProcessInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
+ if (qemuGetProcessInfo(NULL, NULL, &rss, vm->pid, 0, NULL) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("cannot get RSS for domain"));
} else {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d90e6b5..193f501 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -901,6 +901,7 @@ struct remote_domain_get_info_ret { /* insert@1 */
unsigned hyper memory;
unsigned short nrVirtCpu;
unsigned hyper cpuTime;
+ unsigned hyper upTime;
};
struct remote_domain_save_args {
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index e614f77..1f54d5d 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -531,6 +531,7 @@ struct remote_domain_get_info_ret {
uint64_t memory;
u_short nrVirtCpu;
uint64_t cpuTime;
+ uint64_t upTime;
};
struct remote_domain_save_args {
remote_nonnull_domain dom;
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 6951db2..027790f 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1246,6 +1246,14 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed);
}
+ if (info.upTime != 0) {
+ double upTime = info.upTime;
+
+ upTime /= 1000000000.0;
+
+ vshPrint(ctl, "%-15s %.1lfs\n", _("Uptime:"), upTime);
+ }
+
if (info.maxMem != UINT_MAX)
vshPrint(ctl, "%-15s %lu KiB\n", _("Max memory:"),
info.maxMem);
--
2.1.0
9 years, 8 months
[libvirt] [PATCH] qemu: fix crash in qemuProcessAutoDestroy
by Michael Chapman
The destination libvirt daemon in a migration may segfault if the client
disconnects immediately after the migration has begun:
# virsh -c qemu+tls://remote/system list --all
Id Name State
----------------------------------------------------
...
# timeout --signal KILL 1 \
virsh migrate example qemu+tls://remote/system \
--verbose --compressed --live --auto-converge \
--abort-on-error --unsafe --persistent \
--undefinesource --copy-storage-all --xml example.xml
Killed
# virsh -c qemu+tls://remote/system list --all
error: failed to connect to the hypervisor
error: unable to connect to server at 'remote:16514': Connection refused
The crash is in:
1531 void
1532 qemuDomainObjEndJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
1533 {
1534 qemuDomainObjPrivatePtr priv = obj->privateData;
1535 qemuDomainJob job = priv->job.active;
1536
1537 priv->jobs_queued--;
Backtrace:
#0 at qemuDomainObjEndJob at qemu/qemu_domain.c:1537
#1 in qemuDomainRemoveInactive at qemu/qemu_domain.c:2497
#2 in qemuProcessAutoDestroy at qemu/qemu_process.c:5646
#3 in virCloseCallbacksRun at util/virclosecallbacks.c:350
#4 in qemuConnectClose at qemu/qemu_driver.c:1154
...
qemuDomainRemoveInactive calls virDomainObjListRemove, which in this
case is holding the last remaining reference to the domain.
qemuDomainRemoveInactive then calls qemuDomainObjEndJob, but the domain
object has been freed and poisoned by then.
This patch bumps the domain's refcount until qemuDomainRemoveInactive
has completed. We also ensure qemuProcessAutoDestroy does not return the
domain to virCloseCallbacksRun to be unlocked in this case. There is
similar logic in bhyveProcessAutoDestroy and lxcProcessAutoDestroy
(which call virDomainObjListRemove directly).
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/qemu/qemu_domain.c | 5 +++++
src/qemu/qemu_process.c | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 758fcd9..0ae4693 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2487,11 +2487,16 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
VIR_WARN("unable to remove snapshot directory %s", snapDir);
VIR_FREE(snapDir);
}
+
+ virObjectRef(vm);
+
virDomainObjListRemove(driver->domains, vm);
virObjectUnref(cfg);
if (haveJob)
qemuDomainObjEndJob(driver, vm);
+
+ virObjectUnref(vm);
}
void
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 79f763e..fe987c8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5642,8 +5642,10 @@ qemuProcessAutoDestroy(virDomainObjPtr dom,
qemuDomainObjEndJob(driver, dom);
- if (!dom->persistent)
+ if (!dom->persistent) {
qemuDomainRemoveInactive(driver, dom);
+ dom = NULL;
+ }
if (event)
qemuDomainEventQueue(driver, event);
--
2.1.0
9 years, 8 months
[libvirt] [PATCH] build: avoid variable named 'interface', for mingw
by Eric Blake
Commit 2f36e6944 (re-)introduced a use of an identifier 'interface',
which causes this build failure on mingw:
../../tools/virsh-domain-monitor.c: In function 'cmdDomIfAddr':
../../tools/virsh-domain-monitor.c:2233:17: error: expected identifier or '(' before 'struct'
const char *interface = NULL;
^
See also commit 6512c8b. Sadly, I'm not quite sure how to write a
syntax check that can poison the use of this identifier.
* tools/virsh-domain-monitor.c (cmdDomIfAddr): Use ifacestr instead.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
tools/virsh-domain-monitor.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index d307881..6951db2 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1,7 +1,7 @@
/*
* virsh-domain-monitor.c: Commands to monitor domain status
*
- * Copyright (C) 2005, 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -2230,7 +2230,7 @@ static bool
cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- const char *interface = NULL;
+ const char *ifacestr = NULL;
virDomainInterfacePtr *ifaces = NULL;
size_t i, j;
int ifaces_count = 0;
@@ -2242,7 +2242,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
- if (vshCommandOptString(cmd, "interface", &interface) < 0)
+ if (vshCommandOptString(cmd, "interface", &ifacestr) < 0)
goto cleanup;
if (vshCommandOptString(cmd, "source", &sourcestr) < 0)
goto cleanup;
@@ -2273,7 +2273,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
char *ip_addr_str = NULL;
const char *type = NULL;
- if (interface && STRNEQ(interface, iface->name))
+ if (ifacestr && STRNEQ(ifacestr, iface->name))
continue;
/* When the interface has no IP address */
--
2.1.0
9 years, 8 months
[libvirt] Instances
by Dave Sayles
I'm running libvirt with qemu-kvm underneath.
My network stack has the eth0 interface which is bridged to a br0 interface.
Usually, when a VM starts up, a new "vnet" interface is created as well by
libvirt. That vnet interface has a matching HWaddr to the VM that was spun up
with it, so I'm assuming they're associated somehow.
Sometimes, after using libvirt's "virt-install" to create a VM, I'm unable to
"virsh start" it. Virsh will print this out to stderr that it couldn't start
that VM, since the connection was "Reset by peer".
I've yet to find a repro case for this issue. Eventually, I am able to "virsh
start" the instance, but only after several minutes.
Are there any known issues with libvirt/qemu-kvm failing to instantiate
network devices when it spins up VMs?
This is printed to the logs as well:
Mar 27 16:21:07 localhost kernel: device vnet42 entered promiscuous mode
Mar 27 16:21:07 localhost kernel: br0: port 44(vnet42) entering forwarding
state
Mar 27 16:21:07 localhost logger: KVM: 43 guests now active
Mar 27 16:21:08 localhost kernel: br0: port 44(vnet42) entering disabled
state
Mar 27 16:21:08 localhost kernel: device vnet42 left promiscuous mode
Mar 27 16:21:08 localhost kernel: br0: port 44(vnet42) entering disabled
state
Mar 27 16:21:08 localhost logger: KVM: 42 guests now active
9 years, 8 months
Re: [libvirt] GSoC/OPW:Problems Compilling libvirt
by Noella Ashu
Hello Yandong,
(1)As I known, before compiling libvirt, some packages should be installed.
>
> sudo apt-get install gcc make pkg-config libxml2-dev libgnutils-dev
> libdevmapper-dev libcur l4-gnutls-dev python-dev libpciaccess-dev
> libxen-dev libnl-dev
>
>
I just ran $yum builddep libvirt and it installed all the dependencies
for libvirt.
I have successfully compiled libvirt. I'll select some bugs to start
working on.
Thanks,
>
>>
>
>
> --
> ----------------------------------------------------------
> regards,
> yandong
>
>
9 years, 8 months
[libvirt] GSoC/OPW:Problems Compilling libvirt
by Noella Ashu
Hello,
I have been trying to compile libvirt, I have cloned the git repo, tried
running ./configure but it looks like it's not executable. So when I try
running ./autogen.sh script. I get the following errors:
https://paste.kde.org/p8liujgxg
I have tried installing autopoint, python-config. It's not working. Is
there anything I'm missing? I do not see any file listing the dependencies
I have to install.
Thanks,
Noella
9 years, 8 months