[libvirt] [PATCH] snapshot: conf: Forbid using same file as external snapshot for disks and external snapshot for memory
by Shanzhi Yu
When create external system checkpoint snapshot, snapshot file for disks
should not be same with snapshot file for memory
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1148932
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/conf/snapshot_conf.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 1f83b2c..25af914 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -221,6 +221,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
char *tmp;
char *memorySnapshot = NULL;
char *memoryFile = NULL;
+ char *diskFile = NULL;
bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
if (VIR_ALLOC(def) < 0)
@@ -299,6 +300,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
memorySnapshot = virXPathString("string(./memory/@snapshot)", ctxt);
memoryFile = virXPathString("string(./memory/@file)", ctxt);
+ diskFile = virXPathString("string(./disks/disk/source/@file)", ctxt);
if (memorySnapshot) {
def->memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
if (def->memory <= 0) {
@@ -322,6 +324,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
}
} else if (memoryFile) {
def->memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
+ if (diskFile != NULL && STREQ(memoryFile,diskFile)){
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("external snapshot file for disks should not be same"
+ " with external snapshot file for memory"));
+ goto cleanup;
+ }
} else if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
def->memory = (offline ?
VIR_DOMAIN_SNAPSHOT_LOCATION_NONE :
@@ -336,6 +344,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
}
def->file = memoryFile;
memoryFile = NULL;
+ diskFile = NULL;
/* verify that memory path is absolute */
if (def->file && def->file[0] != '/') {
@@ -379,6 +388,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
VIR_FREE(nodes);
VIR_FREE(memorySnapshot);
VIR_FREE(memoryFile);
+ VIR_FREE(diskFile);
if (ret == NULL)
virDomainSnapshotDefFree(def);
--
1.9.3
10 years, 1 month
[libvirt] [PATCH 0/6] handle NIC_RX_FILTER_CHANGED events from qemu
by Laine Stump
These patches set up an event handler for qemu's NIC_RX_FILTER_CHANGED
event, which is sent whenever a guest makes a change to a network
device's unicast/multicast filter, vlan table, or MAC address.
The handler checks if it is appropriate to respond to the
NIC_RX_FILTER_CHANGED event (based on device type and configuration)
and takes appropriate action. Currently it checks if the guest
interface has been configured with trustGuestRxFilters='yes' (defaults
to 'no' for security reasons), and if the host side device is
macvtap. If so, and the MAC address on the guest has changed, the MAC
address of the macvtap device is changed to match.
The result of this is that networking from the guest will continue to
work if the mac address of a macvtap-connected network device is
changed from within the guest, as long as trustGuestRxFilters='yes'
(previously changing the MAC address in the guest would break
networking).
I still need to add code to compare the old and new unicast and
multicast lists and program the filters in the macvtap to match the
guest, and to check for a non-empty vlan table and handle that
(currently that means just setting promiscuous mode on the macvtap),
but that can come in a followup series.
Laine Stump (6):
conf: add trustGuestRxFilters attribute to network and domain
interface
network: set interface actual trustGuestRxFilters from
network/portgroup
util: define virNetDevRxFilter and basic utility functions
qemu: qemuMonitorQueryRxFilter - retrieve guest netdev rx-filter
qemu: setup infrastructure to handle NIC_RX_FILTER_CHANGED event
qemu: change macvtap device MAC address in response to
NIC_RX_FILTER_CHANGED
docs/formatdomain.html.in | 38 +++-
docs/formatnetwork.html.in | 28 ++-
docs/schemas/domaincommon.rng | 5 +
docs/schemas/network.rng | 10 +
src/conf/domain_conf.c | 42 ++++
src/conf/domain_conf.h | 3 +
src/conf/network_conf.c | 35 ++++
src/conf/network_conf.h | 2 +
src/libvirt_private.syms | 9 +
src/network/bridge_driver.c | 11 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 105 ++++++++++
src/qemu/qemu_monitor.c | 39 ++++
src/qemu/qemu_monitor.h | 11 +
src/qemu/qemu_monitor_json.c | 232 +++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 +
src/qemu/qemu_process.c | 42 ++++
src/util/virnetdev.c | 40 ++++
src/util/virnetdev.h | 57 ++++-
tests/Makefile.am | 3 +
tests/networkxml2xmlin/vepa-net.xml | 4 +-
tests/networkxml2xmlout/vepa-net.xml | 4 +-
.../qemuxml2argv-net-virtio-network-portgroup.xml | 4 +-
23 files changed, 711 insertions(+), 17 deletions(-)
--
1.9.3
10 years, 1 month
[libvirt] [PATCH] Fix typo s/EMULATORIN/EMULATORPIN/
by Daniel P. Berrange
Fix the typo in VIR_DOMAIN_TUNABLE_CPU_EMULATORIN
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
include/libvirt/libvirt.h.in | 4 ++--
src/qemu/qemu_driver.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
Pushed under trivial rule
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2ff5204..5217ab3 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -5213,12 +5213,12 @@ typedef void (*virConnectDomainEventDeviceRemovedCallback)(virConnectPtr conn,
#define VIR_DOMAIN_TUNABLE_CPU_VCPUPIN "cputune.vcpupin%u"
/**
- * VIR_DOMAIN_TUNABLE_CPU_EMULATORIN:
+ * VIR_DOMAIN_TUNABLE_CPU_EMULATORPIN:
*
* Macro represents formatted pinning for emulator process,
* as VIR_TYPED_PARAM_STRING.
*/
-#define VIR_DOMAIN_TUNABLE_CPU_EMULATORIN "cputune.emulatorpin"
+#define VIR_DOMAIN_TUNABLE_CPU_EMULATORPIN "cputune.emulatorpin"
/**
* VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES:
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 54119f5..6606154 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4940,7 +4940,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
str = virBitmapFormat(pcpumap);
if (virTypedParamsAddString(&eventParams, &eventNparams,
&eventMaxparams,
- VIR_DOMAIN_TUNABLE_CPU_EMULATORIN,
+ VIR_DOMAIN_TUNABLE_CPU_EMULATORPIN,
str) < 0)
goto cleanup;
--
1.9.3
10 years, 1 month
[libvirt] [libvirt-python PATCH] Post-release version bump for new dev cycle
by Pavel Hrdina
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Pushed under trivial rule
setup.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py
index 167f568..0c34ae1 100755
--- a/setup.py
+++ b/setup.py
@@ -309,7 +309,7 @@ class my_clean(clean):
_c_modules, _py_modules = get_module_lists()
setup(name = 'libvirt-python',
- version = '1.2.9',
+ version = '1.2.10',
url = 'http://www.libvirt.org',
maintainer = 'Libvirt Maintainers',
maintainer_email = 'libvir-list(a)redhat.com',
--
2.0.4
10 years, 1 month
[libvirt] [PATCH 0/2] Fix updating domain live XML
by Erik Skultety
Erik Skultety (2):
qemu: Fix updating bandwidth limits in live XML
qemu: Fix updating balloon period in live XML
src/qemu/qemu_driver.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
--
1.9.3
10 years, 1 month
[libvirt] [PATCH] Add virCgroupTerminateMachine stub
by Ján Tomko
Fix the build on FreeBSD, broken by commit 4882618.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Pushed under the build breaker rule.
src/util/vircgroup.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index d69f71b..9bbe694 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -4029,6 +4029,17 @@ virCgroupNewDetectMachine(const char *name ATTRIBUTE_UNUSED,
return -1;
}
+
+int virCgroupTerminateMachine(const char *name ATTRIBUTE_UNUSED,
+ const char *drivername ATTRIBUTE_UNUSED,
+ bool privileged ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENXIO, "%s",
+ _("Control groups not supported on this platform"));
+ return -1;
+}
+
+
int
virCgroupNewMachine(const char *name ATTRIBUTE_UNUSED,
const char *drivername ATTRIBUTE_UNUSED,
--
2.0.4
10 years, 1 month
[libvirt] [PATCH] build: fix build on non-Linux
by Eric Blake
A cygwin build of 1.2.9 fails with:
util/virprocess.c:87:27: fatal error: sys/syscall.h: No such file or directory
# include <sys/syscall.h>
But in reality, the ONLY user of setns() is lxc, which is Linux-only.
It's easiest to just limit the setns workarounds to Linux.
* src/util/virprocess.c (setns): Limit definition to Linux.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
src/util/virprocess.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 806e7f9..486123a 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -61,44 +61,48 @@
VIR_LOG_INIT("util.process");
+#ifdef __linux__
/*
* Workaround older glibc. While kernel may support the setns
* syscall, the glibc wrapper might not exist. If that's the
* case, use our own.
*/
-#ifndef __NR_setns
-# if defined(__x86_64__)
-# define __NR_setns 308
-# elif defined(__i386__)
-# define __NR_setns 346
-# elif defined(__arm__)
-# define __NR_setns 375
-# elif defined(__aarch64__)
-# define __NR_setns 375
-# elif defined(__powerpc__)
-# define __NR_setns 350
-# elif defined(__s390__)
-# define __NR_setns 339
+# ifndef __NR_setns
+# if defined(__x86_64__)
+# define __NR_setns 308
+# elif defined(__i386__)
+# define __NR_setns 346
+# elif defined(__arm__)
+# define __NR_setns 375
+# elif defined(__aarch64__)
+# define __NR_setns 375
+# elif defined(__powerpc__)
+# define __NR_setns 350
+# elif defined(__s390__)
+# define __NR_setns 339
+# endif
# endif
-#endif
-#ifndef HAVE_SETNS
-# if defined(__NR_setns) && !defined(WIN32)
-# include <sys/syscall.h>
+# ifndef HAVE_SETNS
+# if defined(__NR_setns)
+# include <sys/syscall.h>
static inline int setns(int fd, int nstype)
{
return syscall(__NR_setns, fd, nstype);
}
-# else /* __NR_setns && !WIN32 */
+# else /* !__NR_setns */
+# error Please determine the syscall number for setns on your architecture
+# endif
+# endif
+#else /* !__linux__ */
static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED)
{
virReportSystemError(ENOSYS, "%s",
_("Namespaces are not supported on this platform."));
return -1;
}
-# endif /* __NR_setns && !WIN32 */
-#endif /* HAVE_SETNS */
+#endif
/**
* virProcessTranslateStatus:
--
1.9.3
10 years, 1 month
[libvirt] [PATCH] qemu: use systemd's TerminateMachine to kill all processes
by Guido Günther
If we don't properly clean up all processes in the
machine-<vmname>.scope systemd won't remove the cgroup and subsequent vm
starts fail with
'CreateMachine: File exists'
Additional processes can e.g. be added via
echo $PID > /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks
but there are other cases like
http://bugs.debian.org/761521
Invoke TerminateMachine to be on the safe side since systemd tracks the
cgroup anyway. This is a noop if all processes have terminated already.
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_cgroup.c | 11 ++++++++++-
src/qemu/qemu_cgroup.h | 2 +-
src/qemu/qemu_process.c | 4 ++--
src/util/vircgroup.c | 11 +++++++++++
src/util/vircgroup.h | 5 +++++
6 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 51a692b..99ef1db 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1115,6 +1115,7 @@ virCgroupSetMemorySoftLimit;
virCgroupSetMemSwapHardLimit;
virCgroupSetOwner;
virCgroupSupportsCpuBW;
+virCgroupTerminateMachine;
# util/virclosecallbacks.h
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 7c6b2c1..0ab7227 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1188,13 +1188,22 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm)
}
int
-qemuRemoveCgroup(virDomainObjPtr vm)
+qemuRemoveCgroup(virQEMUDriverPtr driver,
+ virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
if (priv->cgroup == NULL)
return 0; /* Not supported, so claim success */
+ if (virCgroupTerminateMachine(vm->def->name,
+ "qemu",
+ cfg->privileged) < 0) {
+ if (!virCgroupNewIgnoreError())
+ VIR_DEBUG("Failed to terminate cgroup for %s", vm->def->name);
+ }
+
return virCgroupRemove(priv->cgroup);
}
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 8a2c723..4a4f22c 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -66,7 +66,7 @@ int qemuSetupCgroupForIOThreads(virDomainObjPtr vm);
int qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virBitmapPtr nodemask);
-int qemuRemoveCgroup(virDomainObjPtr vm);
+int qemuRemoveCgroup(virQEMUDriverPtr driver, virDomainObjPtr vm);
int qemuAddToCgroup(virDomainObjPtr vm);
#endif /* __QEMU_CGROUP_H__ */
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 13614e9..e7cce1a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4131,7 +4131,7 @@ int qemuProcessStart(virConnectPtr conn,
/* Ensure no historical cgroup for this VM is lying around bogus
* settings */
VIR_DEBUG("Ensuring no historical cgroup is lying around");
- qemuRemoveCgroup(vm);
+ qemuRemoveCgroup(driver, vm);
for (i = 0; i < vm->def->ngraphics; ++i) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
@@ -4909,7 +4909,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
}
retry:
- if ((ret = qemuRemoveCgroup(vm)) < 0) {
+ if ((ret = qemuRemoveCgroup(driver, vm)) < 0) {
if (ret == -EBUSY && (retries++ < 5)) {
usleep(200*1000);
goto retry;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 1dbe6f9..d69f71b 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1680,6 +1680,17 @@ virCgroupNewMachineSystemd(const char *name,
}
+/*
+ * Returns 0 on success, -1 on fatal error
+ */
+int virCgroupTerminateMachine(const char *name,
+ const char *drivername,
+ bool privileged)
+{
+ return virSystemdTerminateMachine(name, drivername, privileged);
+}
+
+
static int
virCgroupNewMachineManual(const char *name,
const char *drivername,
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 19e82d1..7718a07 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -106,6 +106,11 @@ int virCgroupNewMachine(const char *name,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
ATTRIBUTE_NONNULL(4);
+int virCgroupTerminateMachine(const char *name,
+ const char *drivername,
+ bool privileged)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
bool virCgroupNewIgnoreError(void);
void virCgroupFree(virCgroupPtr *group);
--
2.1.0
10 years, 1 month
[libvirt] [PATCH] Make editor used for 'virsh edit' configurable
by Guido Günther
Debian wants to use 'sensible-editor' instead of vi other distros might
want to use other defaults. This avoids distro specific patches.
---
configure.ac | 9 +++++++++
tools/virsh.c | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 0062d5d..f987da2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2773,6 +2773,14 @@ test "x$lv_cv_static_analysis" = xyes && t=1
AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t],
[Define to 1 when performing static analysis.])
+AC_ARG_WITH([default-editor],
+ [AS_HELP_STRING([--with-default-editor],
+ [Editor to use for interactive commands
+ @<:@default=vi@:>@])],
+ [DEFAULT_EDITOR=${withval}],
+ [DEFAULT_EDITOR=vi])
+AC_DEFINE_UNQUOTED([DEFAULT_EDITOR], ["$DEFAULT_EDITOR"], [Default editor to use])
+
# Some GNULIB base64 symbols clash with a kerberos library
AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[Hack to avoid symbol clash])
AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avoid symbol clash])
@@ -2973,6 +2981,7 @@ AC_MSG_NOTICE([ numad: $with_numad])
AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
AC_MSG_NOTICE([ Init script: $with_init_script])
AC_MSG_NOTICE([Char device locks: $with_chrdev_lock_files])
+AC_MSG_NOTICE([ Default Editor: $DEFAULT_EDITOR])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Developer Tools])
AC_MSG_NOTICE([])
diff --git a/tools/virsh.c b/tools/virsh.c
index 64195a4..589f3b4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -785,7 +785,7 @@ vshEditFile(vshControl *ctl, const char *filename)
if (!editor)
editor = virGetEnvBlockSUID("EDITOR");
if (!editor)
- editor = "vi"; /* could be cruel & default to ed(1) here */
+ editor = DEFAULT_EDITOR;
/* Check that filename doesn't contain shell meta-characters, and
* if it does, refuse to run. Follow the Unix conventions for
--
2.1.0
10 years, 1 month