[libvirt] Problems live migrating a Windows VM - Inconsistent?
by Shawn Starr
Hello,
I noticed some issues migrating a VM
1) I had to have ssh key authentication exchanged or it would refuse to
connect tunneled to the remote libvirtd server
2) When it attempts to finish live migrating the VM it fails saying it can't
find the domain on the remote libvirtd server host
However, if I run the command again to migrate, it DOES migrate the VM over, however the Windows guest is not usable, cant type/use mouse, but i can see the VM display fine. I can gracefully shut the VM down from virt-manager and
I see the VM shut down gracefully from display attached via spice.
This seems like two bugs?
Versions:
host kernel: 3.6.0-0.rc7.git0.1.fc18.x86_64
libvirt-XXXXXXX-0.10.2-3.fc18.x86_64
qemu-kvm-1.2.0-8.fc18.x86_64 (will upgrade to latest on koji but unrelated I believe)
Command:
LIBVIRT_DEBUG=1 virsh --debug=4 migrate --verbose --live --tunnelled --p2p Windows_7 qemu+ssh://root@172.18.2.3/system
Output:
...
<snip>
2012-09-30 17:59:14.814+0000: 24710: debug : virKeepAliveCheckMessage:384 : ka=0x266a470, client=0x2669ee0, msg=0x2669f48
2012-09-30 17:59:14.814+0000: 24710: debug : virNetClientIOEventLoopRemoveDone:1380 : Waking up sleep 0x2669cb0
2012-09-30 17:59:14.814+0000: 24708: debug : virNetClientIO:1754 : Woken up from sleep head=0x7f4830400e60 call=0x2669cb0
2012-09-30 17:59:14.814+0000: 24708: debug : virNetClientIO:1807 : All done with our call head=0x7f4830400e60 call=0x2669cb0 rv=0
2012-09-30 17:59:14.814+0000: 24708: debug : virNetMessageFree:73 : msg=0x2669640 nfds=0 cb=(nil)
Migration: [ 95 %]2012-09-30 17:59:15.315+0000: 24708: debug : virDomainGetJobInfo:17129 : dom=0x2669e70, (VM: name=Windows, uuid=41562d70-d0a8-25bc-10ec-a3dc46b3d258), info=0x7fffb64d72d0
2012-09-30 17:59:15.315+0000: 24708: debug : virNetMessageNew:45 : msg=0x2669640 tracked=0
2012-09-30 17:59:15.315+0000: 24708: debug : virNetMessageEncodePayload:358 : Encode length as 64
2012-09-30 17:59:15.315+0000: 24708: debug : virNetClientSendInternal:1955 : RPC_CLIENT_MSG_TX_QUEUE: client=0x2669ee0 len=64 prog=536903814 vers=1 proc=163 type=0 status=0 serial=50
2012-09-30 17:59:15.315+0000: 24708: debug : virNetClientCallNew:1908 : New call 0x2669150: msg=0x2669640, expectReply=1, nonBlock=0
2012-09-30 17:59:15.315+0000: 24708: debug : virNetClientIO:1718 : Outgoing message prog=536903814 version=1 serial=50 proc=163 type=0 length=64 dispatch=0x7f4830400e60
2012-09-30 17:59:15.315+0000: 24708: debug : virNetClientIO:1744 : Going to sleep head=0x7f4830400e60 call=0x2669150
2012-09-30 17:59:15.315+0000: 24710: debug : virNetClientIOEventLoop:1558 : Woken up from poll by other thread
2012-09-30 17:59:15.317+0000: 24710: debug : virNetMessageDecodeLength:152 : Got length, now need 120 total (116 more)
2012-09-30 17:59:15.317+0000: 24710: debug : virNetClientCallDispatch:1127 : RPC_CLIENT_MSG_RX: client=0x2669ee0 len=120 prog=536903814 vers=1 proc=163 type=1 status=0 serial=50
2012-09-30 17:59:15.317+0000: 24710: debug : virKeepAliveCheckMessage:384 : ka=0x266a470, client=0x2669ee0, msg=0x2669f48
2012-09-30 17:59:15.317+0000: 24710: debug : virNetClientIOEventLoopRemoveDone:1380 : Waking up sleep 0x2669150
2012-09-30 17:59:15.317+0000: 24708: debug : virNetClientIO:1754 : Woken up from sleep head=0x7f4830400e60 call=0x2669150
2012-09-30 17:59:15.317+0000: 24708: debug : virNetClientIO:1807 : All done with our call head=0x7f4830400e60 call=0x2669150 rv=0
2012-09-30 17:59:15.317+0000: 24708: debug : virNetMessageFree:73 : msg=0x2669640 nfds=0 cb=(nil)
Migration: [ 95 %]2012-09-30 17:59:15.751+0000: 24710: debug : virNetMessageDecodeLength:152 : Got length, now need 204 total (200 more)
2012-09-30 17:59:15.751+0000: 24710: debug : virNetClientCallDispatch:1127 : RPC_CLIENT_MSG_RX: client=0x2669ee0 len=204 prog=536903814 vers=1 proc=216 type=1 status=1 serial=8
2012-09-30 17:59:15.751+0000: 24710: debug : virKeepAliveCheckMessage:384 : ka=0x266a470, client=0x2669ee0, msg=0x2669f48
2012-09-30 17:59:15.751+0000: 24710: debug : virNetClientIOEventLoopPassTheBuck:1424 : Giving up the buck 0x7f4830400e60
2012-09-30 17:59:15.751+0000: 24710: debug : virNetClientIOEventLoopPassTheBuck:1438 : No thread to pass the buck to
2012-09-30 17:59:15.751+0000: 24710: debug : virEventPollUpdateHandle:146 : EVENT_POLL_UPDATE_HANDLE: watch=2 events=1
2012-09-30 17:59:15.751+0000: 24710: debug : virEventPollInterruptLocked:701 : Interrupting
2012-09-30 17:59:15.751+0000: 24710: debug : virNetClientIO:1807 : All done with our call head=(nil) call=0x7f4830400e60 rv=0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollRunOnce:625 : Poll got 1 event(s)
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollDispatchTimeouts:410 : Dispatch 0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollDispatchHandles:455 : Dispatch 1
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollDispatchHandles:469 : i=0 w=1
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollDispatchHandles:483 : EVENT_POLL_DISPATCH_HANDLE: watch=1 events=1
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupTimeouts:501 : Cleanup 0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupTimeouts:537 : Found 0 out of 0 timeout slots used, releasing 0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupHandles:549 : Cleanup 2
2012-09-30 17:59:15.751+0000: 24709: debug : virEventRunDefaultImpl:244 : running default event implementation
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupTimeouts:501 : Cleanup 0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupTimeouts:537 : Found 0 out of 0 timeout slots used, releasing 0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCleanupHandles:549 : Cleanup 2
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollMakePollFDs:378 : Prepare n=0 w=1, f=4 e=1 d=0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollMakePollFDs:378 : Prepare n=1 w=2, f=6 e=1 d=0
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCalculateTimeout:320 : Calculate expiry of 0 timers
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollCalculateTimeout:346 : Timeout at 0 due in -1 ms
2012-09-30 17:59:15.751+0000: 24709: debug : virEventPollRunOnce:614 : EVENT_POLL_RUN: nhandles=2 timeout=-1
2012-09-30 17:59:15.751+0000: 24710: debug : virNetMessageFree:73 : msg=0x7f4830000de0 nfds=0 cb=(nil)
2012-09-30 17:59:15.751+0000: 24710: debug : virDomainFree:2281 : dom=0x7f4830000af0, (VM: name=Windows, uuid=41562d70-d0a8-25bc-10ec-a3dc46b3d258)
2012-09-30 17:59:15.751+0000: 24710: debug : virObjectUnref:135 : OBJECT_UNREF: obj=0x7f4830000af0
2012-09-30 17:59:15.751+0000: 24710: debug : virObjectUnref:137 : OBJECT_DISPOSE: obj=0x7f4830000af0
2012-09-30 17:59:15.751+0000: 24710: debug : virDomainDispose:225 : release domain 0x7f4830000af0 Windows 41562d70-d0a8-25bc-10ec-a3dc46b3d258
2012-09-30 17:59:15.751+0000: 24710: debug : virObjectUnref:135 : OBJECT_UNREF: obj=0x26693b0
2012-09-30 17:59:15.751+0000: 24708: debug : virDomainFree:2281 : dom=0x2669e70, (VM: name=Windows, uuid=41562d70-d0a8-25bc-10ec-a3dc46b3d258)
2012-09-30 17:59:15.751+0000: 24708: debug : virObjectUnref:135 : OBJECT_UNREF: obj=0x2669e70
2012-09-30 17:59:15.751+0000: 24708: debug : virObjectUnref:137 : OBJECT_DISPOSE: obj=0x2669e70
2012-09-30 17:59:15.751+0000: 24708: debug : virDomainDispose:225 : release domain 0x2669e70 Windows 41562d70-d0a8-25bc-10ec-a3dc46b3d258
2012-09-30 17:59:15.752+0000: 24708: debug : virObjectUnref:135 : OBJECT_UNREF: obj=0x26693b0
2012-09-30 17:59:15.752+0000: 24708: debug : virFileClose:72 : Closed fd 9
2012-09-30 17:59:15.752+0000: 24708: debug : virFileClose:72 : Closed fd 10
error: Domain not found: no domain with matching name 'Windows'
12 years, 1 month
[libvirt] [PATCH] docs: rudimentary phyp documentation
by Eric Blake
Based on a report that phyp is undocumented:
https://www.redhat.com/archives/libvirt-users/2012-July/msg00013.html
* docs/drvphyp.html.in (phyp): New file.
* docs/drivers.html.in: List it.
---
Following up on an old thread. This is probably incomplete or
possibly even inaccurate, but I'd rather have something than nothing.
If I don't get any feedback within a week, I'm pushing this as-is.
docs/drivers.html.in | 1 +
docs/drvphyp.html.in | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 docs/drvphyp.html.in
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index 24387d0..307d286 100644
--- a/docs/drivers.html.in
+++ b/docs/drivers.html.in
@@ -29,6 +29,7 @@
<li><strong><a href="drvvmware.html">VMware Workstation/Player</a></strong></li>
<li><strong><a href="drvxen.html">Xen</a></strong></li>
<li><strong><a href="drvhyperv.html">Microsoft Hyper-V</a></strong></li>
+ <li><strong><a href="drvphyp.html">IBM PowerVM (phyp)</a></strong></li>
</ul>
<h2><a name="storage">Storage drivers</a></h2>
diff --git a/docs/drvphyp.html.in b/docs/drvphyp.html.in
new file mode 100644
index 0000000..7d97fa4
--- /dev/null
+++ b/docs/drvphyp.html.in
@@ -0,0 +1,46 @@
+<html><body>
+ <h1>IBM PowerVM hypervisor driver (phyp)</h1>
+ <ul id="toc"></ul>
+ <p>
+ The IBM PowerVM driver can manage both HMC and IVM PowerVM
+ guests. VIOS connections are tunneled through HMC.
+ </p>
+
+
+ <h2><a name="project">Project Links</a></h2>
+ <ul>
+ <li>
+ The <a href="http://www-03.ibm.com/systems/power/software/virtualization/index.html">IBM
+ PowerVM</a> hypervisor
+ </li>
+ </ul>
+
+
+ <h2><a name="uri">Connections to the PowerVM driver</a></h2>
+ <p>
+ Some example remote connection URIs for the driver are:
+ </p>
+<pre>
+phyp://user@hmc/system (HMC connection)
+phyp://user@ivm/system (IVM connection)
+</pre>
+ <p>
+ <strong>Note</strong>: In contrast to other drivers, the
+ PowerVM (or phyp) driver is a client-side-only driver. Therefore, the
+ <a href="remote.html">remote transport mechanism</a> provided by the
+ remote driver and libvirtd will not work, and you cannot use URIs like
+ <code>phyp+ssh://example.com</code>.
+ </p>
+
+
+ <h3><a name="uriformat">URI Format</a></h3>
+ <p>
+ URIs have this general form (<code>[...]</code> marks an
+ optional part, <code>{...|...}</code> marks a mandatory choice).
+ </p>
+<pre>
+phyp://[username@]{hmc|ivm}/managed_system
+</pre>
+ </p>
+
+</body></html>
--
1.7.11.4
12 years, 1 month
[libvirt] [libvirt-glib 1/2] gobject: Handle PMSUSPENDED state from libvirt
by Christophe Fergeau
Emit a signal when switching to the PMSUSPENDED state, and add
an enum entry to describe this state. This avoids runtime warnings
with newer libvirt.
---
libvirt-gobject/libvirt-gobject-connection.c | 7 +++++++
libvirt-gobject/libvirt-gobject-domain.c | 11 +++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 19 +++++++++++--------
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 428ae38..ad7aa07 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -389,6 +389,13 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
case VIR_DOMAIN_EVENT_SHUTDOWN:
break;
+ case VIR_DOMAIN_EVENT_PMSUSPENDED:
+ if (detail == VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY)
+ g_signal_emit_by_name(gdom, "pmsuspended::memory");
+ else
+ g_warn_if_reached();
+ break;
+
default:
g_warn_if_reached();
}
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index bcfad2a..f8ad493 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -55,6 +55,7 @@ enum {
VIR_RESUMED,
VIR_STOPPED,
VIR_UPDATED,
+ VIR_PMSUSPENDED,
LAST_SIGNAL
};
@@ -225,6 +226,16 @@ static void gvir_domain_class_init(GVirDomainClass *klass)
G_TYPE_NONE,
0);
+ signals[VIR_PMSUSPENDED] = g_signal_new("pmsuspended",
+ G_OBJECT_CLASS_TYPE(object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE |
+ G_SIGNAL_NO_HOOKS | G_SIGNAL_DETAILED,
+ G_STRUCT_OFFSET(GVirDomainClass, pmsuspended),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
g_type_class_add_private(klass, sizeof(GVirDomainPrivate));
}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 7810d1b..fc2db7c 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -66,19 +66,22 @@ struct _GVirDomainClass
void (*resumed)(GVirDomain *dom);
void (*updated)(GVirDomain *dom);
void (*suspended)(GVirDomain *dom);
+ void (*pmsuspended)(GVirDomain *dom);
- gpointer padding[20];
+ gpointer padding[19];
};
typedef enum {
- GVIR_DOMAIN_STATE_NONE = 0, /* no state */
- GVIR_DOMAIN_STATE_RUNNING = 1, /* the domain is running */
- GVIR_DOMAIN_STATE_BLOCKED = 2, /* the domain is blocked on resource */
- GVIR_DOMAIN_STATE_PAUSED = 3, /* the domain is paused by user */
- GVIR_DOMAIN_STATE_SHUTDOWN= 4, /* the domain is being shut down */
- GVIR_DOMAIN_STATE_SHUTOFF = 5, /* the domain is shut off */
- GVIR_DOMAIN_STATE_CRASHED = 6 /* the domain is crashed */
+ GVIR_DOMAIN_STATE_NONE = 0, /* no state */
+ GVIR_DOMAIN_STATE_RUNNING = 1, /* the domain is running */
+ GVIR_DOMAIN_STATE_BLOCKED = 2, /* the domain is blocked on resource */
+ GVIR_DOMAIN_STATE_PAUSED = 3, /* the domain is paused by user */
+ GVIR_DOMAIN_STATE_SHUTDOWN= 4, /* the domain is being shut down */
+ GVIR_DOMAIN_STATE_SHUTOFF = 5, /* the domain is shut off */
+ GVIR_DOMAIN_STATE_CRASHED = 6, /* the domain is crashed */
+ GVIR_DOMAIN_STATE_PMSUSPENDED = 7 /* the domain is suspended by guest
+ power management */
} GVirDomainState;
--
1.7.11.4
12 years, 1 month
[libvirt] only 256 active networks
by Dan Kenigsberg
Hi List, Laine,
Maybe you can help here.
We define 256 bridged networks such as
<network>
<name>vdsm-test244</name>
<uuid>c3acd4c3-37be-3f9d-ee6b-317513015f9e</uuid>
<forward mode='bridge'/>
<bridge name='test244' />
</network>
and end up killing `virsh net-list` with
error: Failed to list active networks
error: too many remote undefineds: 257 > 256
error: Reconnected to the hypervisor
What is this limitation? Why is it there? How can this be extended/avoided?
Dan.
12 years, 1 month
[libvirt] [PATCH v2] Add systemd journal support
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add support for logging to the systemd journal, using its
simple client library. The benefit over syslog is that it
accepts structured log data, so the journald can store
individual items like code file/line/func separately from
the string message. Tools which require structured log
data can then query the journal to extract exactly what
they desire without resorting to string parsing
While systemd provides a simple client library for logging,
it is more convenient for libvirt to directly write its
own client code. This lets us build up the iovec's on
the stack, avoiding the need to alloc memory when writing
log messages.
Changed in v2:
- Add virFormatIntDecimal instead of using snprintf
- Add comment about mkostemp
- Fix declaration of linestr var to use size of linenr
- Wrap in #ifdef __linux__
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/logging.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++
src/util/logging.h | 1 +
src/util/util.c | 30 ++++++++
src/util/util.h | 5 +-
5 files changed, 220 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dab607a..eebc52a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1233,6 +1233,7 @@ virFileUnlock;
virFileWaitForDevices;
virFileWriteStr;
virFindFileInPath;
+virFormatIntDecimal;
virGetGroupID;
virGetGroupName;
virGetHostname;
diff --git a/src/util/logging.c b/src/util/logging.c
index cdd94fd..9e44880 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -35,6 +35,10 @@
#if HAVE_SYSLOG_H
# include <syslog.h>
#endif
+#include <sys/socket.h>
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
#include "virterror_internal.h"
#include "logging.h"
@@ -44,6 +48,7 @@
#include "threads.h"
#include "virfile.h"
#include "virtime.h"
+#include "intprops.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -146,6 +151,8 @@ virLogOutputString(virLogDestination ldest)
return "syslog";
case VIR_LOG_TO_FILE:
return "file";
+ case VIR_LOG_TO_JOURNALD:
+ return "journald";
}
return "unknown";
}
@@ -1020,6 +1027,177 @@ virLogAddOutputToSyslog(virLogPriority priority,
}
return 0;
}
+
+
+# ifdef __linux__
+# define IOVEC_SET_STRING(iov, str) \
+ do { \
+ struct iovec *_i = &(iov); \
+ _i->iov_base = (char*)str; \
+ _i->iov_len = strlen(str); \
+ } while (0)
+
+# define IOVEC_SET_INT(iov, buf, val) \
+ do { \
+ struct iovec *_i = &(iov); \
+ _i->iov_base = virFormatIntDecimal(buf, sizeof(buf), val); \
+ _i->iov_len = strlen(buf); \
+ } while (0)
+
+static int journalfd = -1;
+
+static void
+virLogOutputToJournald(virLogSource source,
+ virLogPriority priority,
+ const char *filename,
+ int linenr,
+ const char *funcname,
+ const char *timestamp ATTRIBUTE_UNUSED,
+ unsigned int flags,
+ const char *rawstr,
+ const char *str ATTRIBUTE_UNUSED,
+ void *data ATTRIBUTE_UNUSED)
+{
+ virCheckFlags(VIR_LOG_STACK_TRACE,);
+ int buffd = -1;
+ size_t niov = 0;
+ struct msghdr mh;
+ struct sockaddr_un sa;
+ union {
+ struct cmsghdr cmsghdr;
+ uint8_t buf[CMSG_SPACE(sizeof(int))];
+ } control;
+ struct cmsghdr *cmsg;
+ /* We use /dev/shm instead of /tmp here, since we want this to
+ * be a tmpfs, and one that is available from early boot on
+ * and where unprivileged users can create files. */
+ char path[] = "/dev/shm/journal.XXXXXX";
+ char priostr[INT_BUFSIZE_BOUND(priority)];
+ char linestr[INT_BUFSIZE_BOUND(linenr)];
+
+ /* First message takes upto 4 iovecs, and each
+ * other field needs 3, assuming they don't have
+ * newlines in them
+ */
+# define IOV_SIZE (4 + (5 * 3))
+ struct iovec iov[IOV_SIZE];
+
+ if (strchr(rawstr, '\n')) {
+ uint64_t nstr;
+ /* If 'str' containes a newline, then we must
+ * encode the string length, since we can't
+ * rely on the newline for the field separator
+ */
+ IOVEC_SET_STRING(iov[niov++], "MESSAGE\n");
+ nstr = htole64(strlen(rawstr));
+ iov[niov].iov_base = (char*)&nstr;
+ iov[niov].iov_len = sizeof(nstr);
+ niov++;
+ } else {
+ IOVEC_SET_STRING(iov[niov++], "MESSAGE=");
+ }
+ IOVEC_SET_STRING(iov[niov++], rawstr);
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ IOVEC_SET_STRING(iov[niov++], "PRIORITY=");
+ IOVEC_SET_INT(iov[niov++], priostr, priority);
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ IOVEC_SET_STRING(iov[niov++], "LIBVIRT_SOURCE=");
+ IOVEC_SET_STRING(iov[niov++], virLogSourceTypeToString(source));
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ IOVEC_SET_STRING(iov[niov++], "CODE_FILE=");
+ IOVEC_SET_STRING(iov[niov++], filename);
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ IOVEC_SET_STRING(iov[niov++], "CODE_LINE=");
+ IOVEC_SET_INT(iov[niov++], linestr, linenr);
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ IOVEC_SET_STRING(iov[niov++], "CODE_FUNC=");
+ IOVEC_SET_STRING(iov[niov++], funcname);
+ IOVEC_SET_STRING(iov[niov++], "\n");
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sun_family = AF_UNIX;
+ if (!virStrcpy(sa.sun_path, "/run/systemd/journal/socket", sizeof(sa.sun_path)))
+ return;
+
+ memset(&mh, 0, sizeof(mh));
+ mh.msg_name = &sa;
+ mh.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path);
+ mh.msg_iov = iov;
+ mh.msg_iovlen = niov;
+
+ if (sendmsg(journalfd, &mh, MSG_NOSIGNAL) >= 0)
+ return;
+
+ if (errno != EMSGSIZE && errno != ENOBUFS)
+ return;
+
+ /* Message was too large, so dump to temporary file
+ * and pass an FD to the journal
+ */
+
+ /* NB: mkostemp is not declared async signal safe by
+ * POSIX, but this is Linux only code and the GLibc
+ * impl is safe enough, only using open() and inline
+ * asm to read a timestamp (falling back to gettimeofday
+ * on some arches
+ */
+ if ((buffd = mkostemp(path, O_CLOEXEC|O_RDWR)) < 0)
+ return;
+
+ if (unlink(path) < 0)
+ goto cleanup;
+
+ if (writev(buffd, iov, niov) < 0)
+ goto cleanup;
+
+ mh.msg_iov = NULL;
+ mh.msg_iovlen = 0;
+
+ memset(&control, 0, sizeof(control));
+ mh.msg_control = &control;
+ mh.msg_controllen = sizeof(control);
+
+ cmsg = CMSG_FIRSTHDR(&mh);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+ memcpy(CMSG_DATA(cmsg), &buffd, sizeof(int));
+
+ mh.msg_controllen = cmsg->cmsg_len;
+
+ sendmsg(journalfd, &mh, MSG_NOSIGNAL);
+
+cleanup:
+ VIR_LOG_CLOSE(buffd);
+}
+
+
+static void virLogCloseJournald(void *data ATTRIBUTE_UNUSED)
+{
+ VIR_LOG_CLOSE(journalfd);
+}
+
+
+static int virLogAddOutputToJournald(int priority)
+{
+ if ((journalfd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0)
+ return -1;
+ if (virSetInherit(journalfd, false) < 0) {
+ VIR_LOG_CLOSE(journalfd);
+ return -1;
+ }
+ if (virLogDefineOutput(virLogOutputToJournald, virLogCloseJournald, NULL,
+ priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) {
+ return -1;
+ }
+ return 0;
+}
+# endif /* __linux__ */
#endif /* HAVE_SYSLOG_H */
#define IS_SPACE(cur) \
@@ -1114,6 +1292,12 @@ virLogParseOutputs(const char *outputs)
count++;
VIR_FREE(name);
VIR_FREE(abspath);
+ } else if (STREQLEN(cur, "journald", 8)) {
+ cur += 8;
+#if HAVE_SYSLOG_H
+ if (virLogAddOutputToJournald(prio) == 0)
+ count++;
+#endif /* HAVE_SYSLOG_H */
} else {
goto cleanup;
}
diff --git a/src/util/logging.h b/src/util/logging.h
index a3ea821..4fe0c8e 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -80,6 +80,7 @@ typedef enum {
VIR_LOG_TO_STDERR = 1,
VIR_LOG_TO_SYSLOG,
VIR_LOG_TO_FILE,
+ VIR_LOG_TO_JOURNALD,
} virLogDestination;
typedef enum {
diff --git a/src/util/util.c b/src/util/util.c
index 28f9ae3..43fdaf1 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2124,6 +2124,36 @@ virDoubleToStr(char **strp, double number)
return ret;
}
+
+/**
+ * Format @val as a base-10 decimal number, in the
+ * buffer @buf of size @buflen. To allocate a suitable
+ * sized buffer, the INT_BUFLEN(int) macro should be
+ * used
+ *
+ * Returns pointer to start of the number in @buf
+ */
+char *
+virFormatIntDecimal(char *buf, size_t buflen, int val)
+{
+ char *p = buf + buflen - 1;
+ *p = '\0';
+ if (val >= 0) {
+ do {
+ *--p = '0' + (val % 10);
+ val /= 10;
+ } while (val != 0);
+ } else {
+ do {
+ *--p = '0' - (val % 10);
+ val /= 10;
+ } while (val != 0);
+ *--p = '-';
+ }
+ return p;
+}
+
+
const char *virEnumToString(const char *const*types,
unsigned int ntypes,
int type)
diff --git a/src/util/util.h b/src/util/util.h
index 5ab36ed..4316ab1 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -210,7 +210,10 @@ char *virStrcpy(char *dest, const char *src, size_t destbytes)
# define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
int virDoubleToStr(char **strp, double number)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
+
+char *virFormatIntDecimal(char *buf, size_t buflen, int val)
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virDiskNameToIndex(const char* str);
char *virIndexToDiskName(int idx, const char *prefix);
--
1.7.11.4
12 years, 1 month
[libvirt] [PATCH 0/3] Transport network port data during live migration
by Kyle Mestery
This series of commits has the end goal of allowing per-port data stored
in the Open vSwitch DB to be transported during live migration. This is
done by first providing a generic infrastructure for transporting network
data, adding some utility functions specific to Open vSwitch, and hooking
the two together.
The framework provided is generic in that other networking data could be
transferred as well by simply adding in additional hooks as needed.
An example of the XML being transported is shown here:
<network>
<interface index='1' vporttype='openvswitch' netdata='blah blah blah'/>
<interface index='7' vporttype='openvswitch' netdata='blah blah blah'/>
</network>
----
- V3 of this patch series fixes issues found by Laine during review around
making the XML more generic.
- V2 of this patch series fixes some issues found when migrating VMs on
standard Linux bridges.
Kyle Mestery (3):
Add the ability for the Qemu V3 migration protocol to include
transporting network configuration. A generic framework is proposed
with this patch to allow for the transfer of opaque data.
Add utility functions for Open vSwitch to both save per-port data
before a live migration, and restore the per-port data after a
live migration.
Transport Open vSwitch per-port data during live migration by
using the utility functions
virNetDevOpenvswitchGetMigrateData() and
virNetDevOpenvswitchSetMigrateData().
src/libvirt_private.syms | 2 +
src/qemu/qemu_migration.c | 293 +++++++++++++++++++++++++++++++++++++++-
src/util/virnetdevopenvswitch.c | 70 ++++++++++
src/util/virnetdevopenvswitch.h | 6 +
4 files changed, 369 insertions(+), 2 deletions(-)
--
1.7.11.4
12 years, 1 month
[libvirt] curious about dnsmasq --conf-file=
by Gene Czarcinski
I understand why there currently is "--conf-file= " on the dnsmasq
command line ... you do not want dnsmasq to use anything in
/etc/dnsmasq.conf.
OK, but dnsmasq is picking up a lot of command line parameters. Why
aren't these parameters put into a libvirt specific conf file such as is
done with radvd?
Is there some reason that only command line parameters are used? I can
understand that it could be a matter of style/personal choice by the
individual that originally did it and, it currently works, so why mess
with it? But, if a patch was created which changed things from the
command line to a conf file, would that be accepted?
BTW, I noticed that there are no tests for what is done with radvd but
there are tests for the dnsmasq command line options. These tests would
no longer apply and thus be deleted. Can anyone cite an example test
for parameters put into a conf file? Or, have some of those tests
become OBE? I must say that I have found the tests valuable in seeing
and debugging additional command line parameters.
Gene
12 years, 1 month
[libvirt] the libnl3-devel problem
by Gene Czarcinski
Is the libnl3-devel problem where, if it is installed, libvirt will
build using libnl3 but, on F17, netcf is still using libnl and the
result is ... not pretty.
If someone believes this is fixed in 0.10.2, they are in error.
Question: Just how hard would be be to get netcf rebuilt and using libnl3?
It is just that I keep getting bit in the rear end by this problem ...
current NetworkManager requires libnl3-devel to build but, if you then
build libvirt without removing libnl3-devel, everything looks good but
it is not.
You would think that I would remember from the last time I went around
with this problem ... but id did not
Gene
12 years, 1 month
[libvirt] [PATCH] Fix (rare) deadlock in QEMU monitor callbacks
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Some users report (very rarely) seeing a deadlock in the QEMU
monitor callbacks
Thread 10 (Thread 0x7fcd11e20700 (LWP 26753)):
at util/threads-pthread.c:85
at conf/domain_conf.c:14256
vm=0x7fcccc00a850) at qemu/qemu_process.c:1026
at qemu/qemu_monitor.c:249
at util/virobject.c:139
at qemu/qemu_monitor.c:860
vm=vm@entry=0x7fcccc00a850,
reason=reason@entry=VIR_DOMAIN_SHUTOFF_DESTROYED, flags=flags@entry=0)
at qemu/qemu_process.c:4057
flags=<optimized out>) at qemu/qemu_driver.c:1977
domain=domain@entry=0x7fccf00c1830, flags=1) at libvirt.c:2256
At frame #10 we are holding the domain lock, we call into
qemuProcessStop() to cleanup QEMU, which triggers the monitor
to close, which invokes qemuProcessHandleMonitorDestroy() which
tries to obtain the domain lock again. This is a non-recursive
lock, hence hang.
Since qemuMonitorPtr is a virObject, the unref call in
qemuProcessHandleMonitorDestroy no longer needs mutex
protection. The assignment of priv->mon = NULL, can be
instead done by the caller of qemuMonitorClose(), thus
removing all need for locking.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_process.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ade64b7..c8c188a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1019,17 +1019,10 @@ no_memory:
}
-static void qemuProcessHandleMonitorDestroy(qemuMonitorPtr mon,
+static void qemuProcessHandleMonitorDestroy(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm)
{
- qemuDomainObjPrivatePtr priv;
-
- virDomainObjLock(vm);
- priv = vm->privateData;
- if (priv->mon == mon)
- priv->mon = NULL;
- if (virObjectUnref(vm))
- virDomainObjUnlock(vm);
+ virObjectUnref(vm);
}
static int
@@ -3995,8 +3988,10 @@ void qemuProcessStop(struct qemud_driver *driver,
priv->agentError = false;
}
- if (priv->mon)
+ if (priv->mon) {
qemuMonitorClose(priv->mon);
+ priv->mon = NULL;
+ }
if (priv->monConfig) {
if (priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX)
--
1.7.11.2
12 years, 1 month
[libvirt] [PATCH] hyperv: Fix and improve hypervListAllDomains
by Matthias Bolte
Use MATCH for all flags checks.
hypervMsvmComputerSystemToDomain expects the domain pointer to the
initialized to NULL.
All items in doms up to the count-th one are valid, no need to double
check before freeing them.
---
I could no runtime-test this because I've have trouble getting my
Hyper-V setup working again.
src/hyperv/hyperv_driver.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 65934c9..349627d 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1302,13 +1302,14 @@ hypervListAllDomains(virConnectPtr conn,
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL);
/* construct query with filter depending on flags */
- if (!(flags & VIR_CONNECT_LIST_DOMAINS_ACTIVE &&
- flags & VIR_CONNECT_LIST_DOMAINS_INACTIVE)) {
- if (flags & VIR_CONNECT_LIST_DOMAINS_ACTIVE) {
+ if (!(MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE) &&
+ MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE))) {
+ if (MATCH(VIR_CONNECT_LIST_DOMAINS_ACTIVE)) {
virBufferAddLit(&query, "and ");
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_ACTIVE);
}
- if (flags & VIR_CONNECT_LIST_DOMAINS_INACTIVE) {
+
+ if (MATCH(VIR_CONNECT_LIST_DOMAINS_INACTIVE)) {
virBufferAddLit(&query, "and ");
virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_INACTIVE);
}
@@ -1358,14 +1359,16 @@ hypervListAllDomains(virConnectPtr conn,
continue;
}
- if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
+ if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
goto no_memory;
+ domain = NULL;
+
if (hypervMsvmComputerSystemToDomain(conn, computerSystem,
&domain) < 0)
goto cleanup;
- doms[count++] = domain;
+ doms[count++] = domain;
}
if (doms)
@@ -1376,13 +1379,14 @@ hypervListAllDomains(virConnectPtr conn,
cleanup:
if (doms) {
for (i = 0; i < count; ++i) {
- if (doms[i])
- virDomainFree(doms[i]);
+ virDomainFree(doms[i]);
}
+
+ VIR_FREE(doms);
}
- VIR_FREE(doms);
hypervFreeObject(priv, (hypervObject *)computerSystemList);
+
return ret;
no_memory:
--
1.7.4.1
12 years, 1 month