[libvirt] New features : cloning
by Clément Valentin
Hi everyone !
I'm currently developing a big project using libvirt to manage ESXi and Xen hypervisor. I was wondering to know if someday libvirt will propose a "cloning" function ?
Thanks for taking time to consider my request.
Valentin
14 years
[libvirt] [PATCH] Don't catch SIGCHLD in libvirtd
by Daniel P. Berrange
libvirtd no longer deals with SIGCHLD in its signal handler
since the QEMU driver switched to always daemonize processes.
Thus remove the sigaction for it, to avoid warning log
messages
* daemon/libvirtd.c: Don't catch SIGCHLD
---
daemon/libvirtd.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index e544c48..2eb2374 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -2973,7 +2973,6 @@ daemonSetupSignals(struct qemud_server *server)
sigaction(SIGINT, &sig_action, NULL);
sigaction(SIGQUIT, &sig_action, NULL);
sigaction(SIGTERM, &sig_action, NULL);
- sigaction(SIGCHLD, &sig_action, NULL);
sig_action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &sig_action, NULL);
--
1.7.2.3
14 years
[libvirt] [PATCH] Include a thread identifier in log messages
by Daniel P. Berrange
To allow messages from different threads to be untangled,
include an integer thread identifier in log messages.
* src/util/logging.c: Include thread ID
* src/util/threads.h, src/util/threads.h, src/util/threads-pthread.c:
Add new virThreadSelfID() function
* configure.ac: Check for sys/syscall.h
---
configure.ac | 2 +-
src/libvirt_private.syms | 1 +
src/util/logging.c | 6 ++++--
src/util/threads-pthread.c | 16 ++++++++++++++++
src/util/threads-win32.c | 16 ++++++++++++++++
src/util/threads.h | 1 +
6 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index b912a7a..af1dfec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,7 +110,7 @@ LIBS=$old_libs
dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/syslimits.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
- sys/un.h])
+ sys/un.h sys/syscall.h])
AC_CHECK_LIB([intl],[gettext],[])
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e808375..3bb1762 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -781,6 +781,7 @@ virThreadCreate;
virThreadIsSelf;
virThreadJoin;
virThreadSelf;
+virThreadSelfID;
# usb.h
diff --git a/src/util/logging.c b/src/util/logging.c
index ac38d4d..d65dec0 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -548,14 +548,16 @@ void virLogMessage(const char *category, int priority, const char *funcname,
localtime_r(&cur_time.tv_sec, &time_info);
if ((funcname != NULL)) {
- ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s:%lld : %s\n",
+ ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %d: %s : %s:%lld : %s\n",
time_info.tm_hour, time_info.tm_min,
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
+ virThreadSelfID(),
virLogPriorityString(priority), funcname, linenr, str);
} else {
- ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %s : %s\n",
+ ret = virAsprintf(&msg, "%02d:%02d:%02d.%03d: %d: %s : %s\n",
time_info.tm_hour, time_info.tm_min,
time_info.tm_sec, (int) cur_time.tv_usec / 1000,
+ virThreadSelfID(),
virLogPriorityString(priority), str);
}
VIR_FREE(str);
diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 34d9ce8..02070ae 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -21,6 +21,11 @@
#include <config.h>
+#include <unistd.h>
+#if HAVE_SYS_SYSCALL_H
+# include <sys/syscall.h>
+#endif
+
/* Nothing special required for pthreads */
int virThreadInitialize(void)
@@ -170,6 +175,17 @@ bool virThreadIsSelf(virThreadPtr thread)
return pthread_equal(pthread_self(), thread->thread) ? true : false;
}
+int virThreadSelfID(void)
+{
+#if defined(HAVE_SYS_SYSCALL_H) && defined(SYS_gettid)
+ pid_t tid;
+ tid = syscall(SYS_gettid);
+ return (int)tid;
+#else
+ return (int)pthread_self();
+#endif
+}
+
void virThreadJoin(virThreadPtr thread)
{
pthread_join(thread->thread, NULL);
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index de73fd5..45c7eef 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -288,6 +288,22 @@ bool virThreadIsSelf(virThreadPtr thread)
return self.thread == thread->thread ? true : false;
}
+int virThreadSelfID(void)
+{
+ HANDLE handle = GetCurrentThread();
+ HANDLE process = GetCurrentProcess();
+ HANDLE thread;
+ int id;
+
+ DuplicateHandle(process, handle, process,
+ &thread, 0, FALSE,
+ DUPLICATE_SAME_ACCESS);
+ id = (int)thread;
+ CloseHandle(thread);
+ return id;
+}
+
+
void virThreadJoin(virThreadPtr thread)
{
if (thread->joinable) {
diff --git a/src/util/threads.h b/src/util/threads.h
index b3b827d..fa00a91 100644
--- a/src/util/threads.h
+++ b/src/util/threads.h
@@ -51,6 +51,7 @@ int virThreadCreate(virThreadPtr thread,
void virThreadSelf(virThreadPtr thread);
bool virThreadIsSelf(virThreadPtr thread);
void virThreadJoin(virThreadPtr thread);
+int virThreadSelfID(void);
int virMutexInit(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
int virMutexInitRecursive(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
--
1.7.2.3
14 years
[libvirt] [PATCH 0/6 v2] xen: parsing and sexpr escaping fixes
by Cole Robinson
This series fixes some xen XM parsing and sexpr generation issues.
The first three patches fix parsing /etc/xen files that use python style
triple quotes (which libvirt will actually generate in certain situations).
The last three patches fix generating xend sexpr with the reserved characters
& \ or '
v2:
Tweak domain schema path usage
Cleanup virBufferEscape*
Small improvements in xend sexpr formatting
More sensible values in sexpr escape tests
Cole Robinson (6):
schemas: domain: Add more valid file path chars
conf: Convert ParseString to use STRPREFIX
conf: Fix parsing python style triple quotes
xend: urlencode: Properly escape '&'
buf: Simplify virBufferEscapeString
xend: Escape reserved sexpr characters
docs/schemas/domain.rng | 23 ++----
src/util/buf.c | 79 ++++++++++++++------
src/util/buf.h | 1 +
src/util/conf.c | 20 +++--
src/xen/xend_internal.c | 113 +++++++++++++++------------
tests/xmconfigdata/test-escape-paths.cfg | 2 +-
tests/xmconfigdata/test-escape-paths.xml | 5 +
tests/xml2sexprdata/xml2sexpr-escape.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-escape.xml | 24 ++++++
tests/xml2sexprtest.c | 1 +
10 files changed, 172 insertions(+), 97 deletions(-)
create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.sexpr
create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.xml
--
1.7.3.2
14 years
[libvirt] [PATCH] qed: Minor updates to QED support patches
by Adam Litke
This patch makes two corrections to the newly-added QED support patch series:
- Correct the QED header field offsets
- Remove XML parsing for VIR_STORAGE_FILE_AUTO_SAFE
Signed-off-by: Adam Litke <agl(a)us.ibm.com>
---
src/util/storage_file.c | 6 +++---
src/util/storage_file.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index aa117e7..2612eb6 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -42,7 +42,7 @@
VIR_ENUM_IMPL(virStorageFileFormat,
VIR_STORAGE_FILE_LAST,
- "raw", "probe", "dir", "bochs",
+ "raw", "dir", "bochs",
"cloop", "cow", "dmg", "iso",
"qcow", "qcow2", "qed", "vmdk", "vpc")
@@ -108,8 +108,8 @@ qedGetBackingStore(char **, int *, const unsigned char *, size_t);
#define QCOW2_HDR_EXTENSION_BACKING_FORMAT 0xE2792ACA
#define QED_HDR_FEATURES_OFFSET (4+4+4+4)
-#define QED_HDR_IMAGE_SIZE (QED_HDR_FEATURES_OFFSET+8+8+8)
-#define QED_HDR_BACKING_FILE_OFFSET (QED_HDR_IMAGE_SIZE+8+8)
+#define QED_HDR_IMAGE_SIZE (QED_HDR_FEATURES_OFFSET+8+8+8+8)
+#define QED_HDR_BACKING_FILE_OFFSET (QED_HDR_IMAGE_SIZE+8)
#define QED_HDR_BACKING_FILE_SIZE (QED_HDR_BACKING_FILE_OFFSET+4)
#define QED_F_BACKING_FILE 0x01
#define QED_F_BACKING_FORMAT_NO_PROBE 0x04
diff --git a/src/util/storage_file.h b/src/util/storage_file.h
index 1b91830..04c1bb2 100644
--- a/src/util/storage_file.h
+++ b/src/util/storage_file.h
@@ -28,9 +28,9 @@
# include <stdbool.h>
enum virStorageFileFormat {
+ VIR_STORAGE_FILE_AUTO_SAFE = -2,
VIR_STORAGE_FILE_AUTO = -1,
VIR_STORAGE_FILE_RAW = 0,
- VIR_STORAGE_FILE_AUTO_SAFE,
VIR_STORAGE_FILE_DIR,
VIR_STORAGE_FILE_BOCHS,
VIR_STORAGE_FILE_CLOOP,
--
1.7.3.2.164.g6f10c
14 years
[libvirt] [PATCH] Remove trailing ':' from timestamp
by Daniel P. Berrange
The QEMU logger appends a ':' to the timestamp when it deems
it neccessary, so the virTimestamp API should not duplicate
this
* src/util/util.c: Remove trailing ':' from timestamp
---
src/util/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index a0849e1..a2582aa 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2930,7 +2930,7 @@ virTimestamp(void)
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", &time_info);
- if (virAsprintf(×tamp, "%s.%03d: ",
+ if (virAsprintf(×tamp, "%s.%03d",
timestr, (int) cur_time.tv_usec / 1000) < 0) {
return NULL;
}
--
1.7.2.3
14 years
[libvirt] [PATCH] Ensure logfile isn't truncated by shutdown message.
by Daniel P. Berrange
When running non-root, the QEMU log file is usually opened with
truncation, since there is no logrotate for non-root usage.
This means that when libvirt logs the shutdown timestamp, the
log is accidentally truncated
* src/qemu/qemu_driver.c: Never truncate log file with shutdown
message
---
src/qemu/qemu_driver.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bf6cd0e..2a686dc 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -741,7 +741,7 @@ static int qemuCgroupControllerActive(struct qemud_driver *driver,
}
static int
-qemudLogFD(struct qemud_driver *driver, const char* name)
+qemudLogFD(struct qemud_driver *driver, const char* name, bool append)
{
char logfile[PATH_MAX];
mode_t logmode;
@@ -756,7 +756,7 @@ qemudLogFD(struct qemud_driver *driver, const char* name)
logmode = O_CREAT | O_WRONLY;
/* Only logrotate files in /var/log, so only append if running privileged */
- if (driver->privileged)
+ if (driver->privileged || append)
logmode |= O_APPEND;
else
logmode |= O_TRUNC;
@@ -3964,7 +3964,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
}
DEBUG0("Creating domain log file");
- if ((logfile = qemudLogFD(driver, vm->def->name)) < 0)
+ if ((logfile = qemudLogFD(driver, vm->def->name, false)) < 0)
goto cleanup;
DEBUG0("Determing emulator version");
@@ -4245,7 +4245,7 @@ static void qemudShutdownVMDaemon(struct qemud_driver *driver,
VIR_DEBUG("Shutting down VM '%s' pid=%d migrated=%d",
vm->def->name, vm->pid, migrated);
- if ((logfile = qemudLogFD(driver, vm->def->name)) < 0) {
+ if ((logfile = qemudLogFD(driver, vm->def->name, true)) < 0) {
/* To not break the normal domain shutdown process, skip the
* timestamp log writing if failed on opening log file. */
VIR_WARN("Unable to open logfile: %s",
--
1.7.2.3
14 years
[libvirt] [PATCH 0/4] Support the QED disk image format (V3)
by Adam Litke
Changes since V2:
- VIR_STORAGE_FILE_AUTO_SAFE is not XML parsable
- Break out QED header defines by field and add link to QED spec
- Removed redundant overflow check in qedGetBackingStore
Changes since V1:
- Fix virStorageFileMatchesVersion() for formats without version info
- Allow backingStore format probing for QED images since it is safe
Qemu is about to gain support for a new disk image format: QED. Details on
this format (including specification) can be found here:
http://wiki.qemu.org/Features/QED. This short series of patches allows QED
images to be used with libvirt.
Adam Litke (4):
Allow probing of image formats without version information
QED: Basic support for QED images
storage_file: Add a new flag to mark backing files that are safe to
probe
Support for probing qed image metadata
src/conf/domain_conf.c | 4 ++
src/util/storage_file.c | 86 +++++++++++++++++++++++++++++++++++++++++++++-
src/util/storage_file.h | 2 +
3 files changed, 90 insertions(+), 2 deletions(-)
--
1.7.3.2.164.g6f10c
14 years
[libvirt] [PATCH 0/4] xen: parsing and sexpr escaping fixes
by Cole Robinson
This series fixes some xen XM parsing and sexpr generation issues.
The first two patches fix parsing /etc/xen files that use python style
triple quotes (which libvirt will actually generate in certain situations).
The last two patches fix generating xend sexpr with the reserved characters
& \ or '
Cole Robinson (4):
conf: Convert ParseString to use STRPREFIX
conf: Fix parsing python style triple quotes
xend: urlencode: Properly escape '&'
xend: Escape reserved sexpr characters
docs/schemas/domain.rng | 10 +-
src/util/buf.c | 79 +++++++++++++++++++
src/util/buf.h | 1 +
src/util/conf.c | 20 +++--
src/xen/xend_internal.c | 116 +++++++++++++++------------
tests/xmconfigdata/test-escape-paths.cfg | 2 +-
tests/xmconfigdata/test-escape-paths.xml | 5 +
tests/xml2sexprdata/xml2sexpr-escape.sexpr | 1 +
tests/xml2sexprdata/xml2sexpr-escape.xml | 24 ++++++
tests/xml2sexprtest.c | 1 +
10 files changed, 193 insertions(+), 66 deletions(-)
create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.sexpr
create mode 100644 tests/xml2sexprdata/xml2sexpr-escape.xml
--
1.7.3.2
14 years
[libvirt] [PATCH] docs: removed outdated reference to virt-mem
by Justin Clift
The virt-mem program is no longer shipped, but was still being
referenced at the bottom of the virsh and libvirtd man pages.
This patch removes it from those man pages, addressing
BZ# 639603:
https://bugzilla.redhat.com/show_bug.cgi?id=639603
---
daemon/libvirtd.pod.in | 2 +-
tools/virsh.pod | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/daemon/libvirtd.pod.in b/daemon/libvirtd.pod.in
index 04a4cb4..6e699b8 100644
--- a/daemon/libvirtd.pod.in
+++ b/daemon/libvirtd.pod.in
@@ -163,6 +163,6 @@ PURPOSE
=head1 SEE ALSO
L<virsh(1)>, L<virt-install(1)>, L<virt-xml-validate(1)>, L<virt-top(1)>,
-L<virt-mem(1)>, L<virt-df(1)>, L<http://www.libvirt.org/>
+L<virt-df(1)>, L<http://www.libvirt.org/>
=cut
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 5a96116..c97786a 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1259,6 +1259,7 @@ PURPOSE
=head1 SEE ALSO
-L<virt-install(1)>, L<virt-xml-validate(1)>, L<virt-top(1)>, L<virt-mem(1)>, L<virt-df(1)>, L<http://www.libvirt.org/>
+L<virt-install(1)>, L<virt-xml-validate(1)>, L<virt-top(1)>, L<virt-df(1)>,
+L<http://www.libvirt.org/>
=cut
--
1.7.3.2
14 years