[libvirt] xenUnifiedDomainLookupByName error handling
by John Levon
We do:
700 /* Not found. */
701 xenUnifiedError (conn, VIR_ERR_NO_DOMAIN, __FUNCTION__);
But:
# virsh start domu-defefe
12:09:30.581: error : Domain not found: xenUnifiedDomainLookupByName
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName
error: failed to get domain 'domu-defefe'
It doesn't seem right to be reporting errors like this. What's the
intent? Most of xenUnifiedError() seems to be internal errors, but many
of them are just clients doing the wrong thing...
regards
john
15 years, 10 months
[libvirt] [PATCH] Fix activeDomainList handling
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1231958879 28800
# Node ID 1fca4b0dd4c6ab3c0030b4986de6fe5cb7c94631
# Parent 097f5b4497d7ecc5cce14d10559244313d26ce46
Fix activeDomainList handling
It must be NULLed out after free()ing.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xs_internal.c b/src/xs_internal.c
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -388,8 +388,10 @@ xenStoreClose(virConnectPtr conn)
}
xenStoreWatchListFree(priv->xsWatchList);
+ priv->xsWatchList = NULL;
#ifndef PROXY
xenUnifiedDomainInfoListFree(activeDomainList);
+ activeDomainList = NULL;
#endif
if (priv->xshandle == NULL)
return(-1);
15 years, 10 months
[libvirt] [PATCH] Fix xs_unwatch() to correctly pass the token
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1231958879 28800
# Node ID 672cdb87a32fb0b275bb7cdc9abb9c2d506ec1b0
# Parent 46dc909bda5b20d11f08d1516f21c05f27b6648f
Fix xs_unwatch() to correctly pass the token
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xs_internal.c b/src/xs_internal.c
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -1106,7 +1106,7 @@ int xenStoreRemoveWatch(virConnectPtr co
if (!xs_unwatch(priv->xshandle,
list->watches[i]->path,
- list->watches[i]->path))
+ list->watches[i]->token))
{
DEBUG0("WARNING: Could not remove watch");
/* Not fatal, continue */
15 years, 10 months
[libvirt] [PATCH] Fix ref-counting for Xen driver event registration
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1231958879 28800
# Node ID 46dc909bda5b20d11f08d1516f21c05f27b6648f
# Parent 1fca4b0dd4c6ab3c0030b4986de6fe5cb7c94631
Fix ref-counting for Xen driver event registration
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xen_unified.c b/src/xen_unified.c
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -1359,15 +1359,21 @@ xenUnifiedDomainEventRegister (virConnec
void *opaque,
void (*freefunc)(void *))
{
+ int ret;
+
GET_PRIVATE (conn);
if (priv->xsWatch == -1) {
xenUnifiedError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
return -1;
}
- conn->refs++;
- return virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
- callback, opaque, freefunc);
+ ret = virDomainEventCallbackListAdd(conn, priv->domainEventCallbacks,
+ callback, opaque, freefunc);
+
+ if (ret == 0)
+ conn->refs++;
+
+ return (ret);
}
static int
@@ -1382,8 +1388,10 @@ xenUnifiedDomainEventDeregister (virConn
}
ret = virDomainEventCallbackListRemove(conn, priv->domainEventCallbacks,
- callback);
- virUnrefConnect(conn);
+ callback);
+
+ if (ret == 0)
+ virUnrefConnect(conn);
return ret;
}
15 years, 10 months
[libvirt] libvirt-qpid and migrate issue
by Ian Main
Howdy all!
So in working with libvirt-qpid, I've come to realize that it imposes a
new difficulty in doing migrations. Traditionally you would connect
out to each individual libvirt instance from a central location and be
able to pass the destination connection pointer to the virDomainMigrate
function. However in libvirt-qpids case, since it's running on each
physical host, it does not necessarily have access to the destination
host due to authentication requirements.
So I'd like to discuss possible ways of resolving this issue. I'm not
sure how much support libvirt proper wants to extend to allowing this
case to work, but I'm hoping we can figure something out that will make
everyone happy.
I see that in the implementation of virDomainMigrate, it is already
split up into prepare and preform functions. I'm thinking that, if
agreeable by the libvirt team, it'd be nice to have an API which
allowed us to call into destination and source nodes separately.
Something like:
char * virConnectMigratePrepare(virConnectPtr conn,
unsigned long flags,
const char *dname);
which would set up the destination node to receive a migrating domain
and return an xml document containing the information required to
perform the migration (host name, port, maybe even capabilities and/or
encryption keys in the future etc.), coupled with:
int virDomainMigratePerform(virDomainPtr dom,
const char *prepare_description,
unsigned long bandwidth);
which would initiate the transfer of the domain to the destination host.
Or something along those lines.. this is just off the top of my head
but I wanted to get the discussion going. Note I'm using the same
internal names prepare/perform but we can rename them if appropriate.
Anyway this would allow us to hook these up in qpid where we have
access to both systems and call them in sequence.
Let me know what you think.
Thanks,
Ian
15 years, 10 months
[libvirt] [PATCH] Implement capabilities for Solaris
by john.levon@sun.com
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1231940906 28800
# Node ID a0d98d39955f4f304d318c7c780742ab929eb351
# Parent ddfcba6b4181ab433dce345d66dc399a81c92a3b
Implement capabilities for Solaris
Use Solaris interfaces to derive the hypervisor capabilities.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/xen_internal.c b/src/xen_internal.c
--- a/src/xen_internal.c
+++ b/src/xen_internal.c
@@ -35,6 +35,10 @@
#ifdef HAVE_XEN_SYS_PRIVCMD_H
#include <xen/sys/privcmd.h>
#endif
+#endif
+
+#ifdef __sun
+#include <sys/systeminfo.h>
#endif
/* required for shutdown flags */
@@ -662,11 +666,8 @@ typedef struct xen_op_v2_dom xen_op_v2_d
#ifdef __linux__
#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
#define HYPERVISOR_CAPABILITIES "/sys/hypervisor/properties/capabilities"
-#define CPUINFO "/proc/cpuinfo"
#elif defined(__sun)
#define XEN_HYPERVISOR_SOCKET "/dev/xen/privcmd"
-#define HYPERVISOR_CAPABILITIES ""
-#define CPUINFO "/dev/cpu/self/cpuid"
#else
#error "unsupported platform"
#endif
@@ -2123,7 +2124,7 @@ xenHypervisorBuildCapabilities(virConnec
xenHypervisorBuildCapabilities(virConnectPtr conn,
const char *hostmachine,
int host_pae,
- char *hvm_type,
+ const char *hvm_type,
struct guest_arch *guest_archs,
int nr_guest_archs) {
virCapsPtr caps;
@@ -2227,8 +2228,126 @@ xenHypervisorBuildCapabilities(virConnec
return NULL;
}
-/**
- * xenHypervisorGetCapabilities:
+#ifdef __sun
+
+static int
+get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode)
+{
+ struct {
+ uint32_t r_eax, r_ebx, r_ecx, r_edx;
+ } regs;
+
+ char tmpbuf[20];
+ int fd = -1;
+ int ret = 0;
+
+ /* returns -1, errno 22 if in 32-bit mode */
+ *longmode = (sysinfo(SI_ARCHITECTURE_64, tmpbuf, 20) != -1);
+
+ if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 ||
+ pread(fd, ®s, sizeof(regs), 0) != sizeof(regs)) {
+ virXenError(conn, VIR_ERR_SYSTEM_ERROR,
+ "couldn't read CPU flags: %s", strerror(errno));
+ goto out;
+ }
+
+ *pae = 0;
+ *hvm = "";
+
+ if (strncmp((const char *)®s.r_ebx, "AuthcAMDenti", 12) == 0) {
+ if (pread(fd, ®s, sizeof (regs), 0x80000001) == sizeof (regs)) {
+ /* Read secure virtual machine bit (bit 2 of ECX feature ID) */
+ if ((regs.r_ecx >> 2) & 1) {
+ *hvm = "svm";
+ }
+ if ((regs.r_edx >> 6) & 1)
+ *pae = 1;
+ }
+ } else if (strncmp((const char *)®s.r_ebx, "GenuntelineI", 12) == 0) {
+ if (pread(fd, ®s, sizeof (regs), 0x00000001) == sizeof (regs)) {
+ /* Read VMXE feature bit (bit 5 of ECX feature ID) */
+ if ((regs.r_ecx >> 5) & 1)
+ *hvm = "vmx";
+ if ((regs.r_edx >> 6) & 1)
+ *pae = 1;
+ }
+ }
+
+ ret = 1;
+
+out:
+ if (fd != -1)
+ close(fd);
+ return ret;
+}
+
+static virCapsPtr
+xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
+{
+ struct guest_arch guest_arches[32];
+ int i = 0;
+ virCapsPtr caps = NULL;
+ struct utsname utsname;
+ int pae, longmode;
+ const char *hvm;
+
+ if (!get_cpu_flags(conn, &hvm, &pae, &longmode))
+ return NULL;
+
+ /* Really, this never fails - look at the man-page. */
+ uname (&utsname);
+
+ guest_arches[i].model = "i686";
+ guest_arches[i].bits = 32;
+ guest_arches[i].hvm = 0;
+ guest_arches[i].pae = pae;
+ guest_arches[i].nonpae = 1;
+ guest_arches[i].ia64_be = 0;
+ i++;
+
+ if (longmode) {
+ guest_arches[i].model = "x86_64";
+ guest_arches[i].bits = 64;
+ guest_arches[i].hvm = 0;
+ guest_arches[i].pae = 0;
+ guest_arches[i].nonpae = 1;
+ guest_arches[i].ia64_be = 0;
+ i++;
+ }
+
+ if (hvm[0] != '\0') {
+ guest_arches[i].model = "i686";
+ guest_arches[i].bits = 32;
+ guest_arches[i].hvm = 1;
+ guest_arches[i].pae = pae;
+ guest_arches[i].nonpae = 1;
+ guest_arches[i].ia64_be = 0;
+ i++;
+
+ if (longmode) {
+ guest_arches[i].model = "x86_64";
+ guest_arches[i].bits = 64;
+ guest_arches[i].hvm = 1;
+ guest_arches[i].pae = 0;
+ guest_arches[i].nonpae = 1;
+ guest_arches[i].ia64_be = 0;
+ i++;
+ }
+ }
+
+ if ((caps = xenHypervisorBuildCapabilities(conn,
+ utsname.machine,
+ pae, hvm,
+ guest_arches, i)) == NULL)
+ virXenError(NULL, VIR_ERR_NO_MEMORY, NULL);
+
+ return caps;
+}
+
+#endif /* __sun */
+
+/**
+ * xenHypervisorMakeCapabilitiesInternal:
* @conn: pointer to the connection block
* @cpuinfo: file handle containing /proc/cpuinfo data, or NULL
* @capabilities: file handle containing /sys/hypervisor/properties/capabilities data, or NULL
@@ -2394,6 +2513,9 @@ virCapsPtr
virCapsPtr
xenHypervisorMakeCapabilities(virConnectPtr conn)
{
+#ifdef __sun
+ return xenHypervisorMakeCapabilitiesSunOS(conn);
+#else
virCapsPtr caps;
FILE *cpuinfo, *capabilities;
struct utsname utsname;
@@ -2432,6 +2554,7 @@ xenHypervisorMakeCapabilities(virConnect
fclose(capabilities);
return caps;
+#endif /* __sun */
}
15 years, 10 months
[libvirt] [PATCH] Remove references to non-existent files
by john.levon@sun.com
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1231946129 28800
# Node ID 9d8302140e58e20c7fb22b3242a52b06467b08e6
# Parent b614f5780261464e8f10e48306e67d43d56931b0
Remove references to non-existent files
Some docs files don't exist.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/docs/Makefile.am b/docs/Makefile.am
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -130,9 +130,8 @@ rebuild: api all
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
- -@INSTALL@ -m 0644 $(srcdir)/libvir.html $(srcdir)/FAQ.html \
- $(srcdir)/redhat.gif $(srcdir)/Libxml2-Logo-90x34.gif \
- $(DESTDIR)$(HTML_DIR)
+ -@INSTALL@ -m 0644 $(srcdir)/FAQ.html \
+ $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(HTML_DIR)
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)/html
for h in $(apihtml); do \
$(INSTALL) -m 0644 $(srcdir)/$$h $(DESTDIR)$(HTML_DIR)/html; done
diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am
--- a/docs/examples/Makefile.am
+++ b/docs/examples/Makefile.am
@@ -20,7 +20,7 @@ install-data-local:
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(HTML_DIR)
-@INSTALL@ -m 0644 $(srcdir)/*.html $(srcdir)/*.c $(srcdir)/*.xml \
- $(srcdir)/*.xsl $(srcdir)/*.res $(DESTDIR)$(HTML_DIR)
+ $(srcdir)/*.xsl $(DESTDIR)$(HTML_DIR)
EXTRA_DIST=examples.xsl index.py examples.xml
diff --git a/docs/examples/index.py b/docs/examples/index.py
--- a/docs/examples/index.py
+++ b/docs/examples/index.py
@@ -218,8 +218,6 @@ def dump_Makefile():
def dump_Makefile():
for file in glob.glob('*.xml'):
extras.append(file)
- for file in glob.glob('*.res'):
- extras.append(file)
Makefile="""# -*- buffer-read-only: t -*- vi: set ro:
# Beware this is autogenerated by index.py
SUBDIRS=python
15 years, 10 months
[libvirt] [PATCH] Separate objdir build fixes
by john.levon@sun.com
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1231946129 28800
# Node ID b614f5780261464e8f10e48306e67d43d56931b0
# Parent 53c621a65055f4752abef748c0ad15cbb1d8013d
Separate objdir build fixes
Let devhelp build in a separate objdir.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/docs/devhelp/Makefile.am b/docs/devhelp/Makefile.am
--- a/docs/devhelp/Makefile.am
+++ b/docs/devhelp/Makefile.am
@@ -1,7 +1,8 @@ DEVHELP_DIR=$(datadir)/gtk-doc/html/libv
DEVHELP_DIR=$(datadir)/gtk-doc/html/libvirt
HTML_FILES=index.html general.html $(HTML_MODULES)
HTML_MODULES= \
- libvirt-libvirt.html
+ libvirt-libvirt.html \
+ libvirt-virterror.html
EXTRA_FORMAT= \
home.png \
@@ -17,11 +18,12 @@ libvirt.devhelp $(HTML_FILES): $(srcdir)
libvirt.devhelp $(HTML_FILES): $(srcdir)/devhelp.xsl html.xsl $(top_srcdir)/docs/libvirt-api.xml
-@(echo Rebuilding devhelp files)
-@(if [ -x $(XSLTPROC) ] ; then \
- $(XSLTPROC) --nonet -o $(srcdir)/libvirt.devhelp $(srcdir)/devhelp.xsl $(top_srcdir)/docs/libvirt-api.xml ; fi );
+ $(XSLTPROC) --nonet -o libvirt.devhelp $(srcdir)/devhelp.xsl $(top_srcdir)/docs/libvirt-api.xml ; fi );
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(DEVHELP_DIR)
-@INSTALL@ -m 0644 libvirt.devhelp $(DESTDIR)$(DEVHELP_DIR)
- -@INSTALL@ -m 0644 $(EXTRA_FORMAT) $(DESTDIR)$(DEVHELP_DIR)
-@INSTALL@ -m 0644 $(HTML_FILES) $(DESTDIR)$(DEVHELP_DIR)
-
+ -for file in $(EXTRA_FORMAT); do \
+ @INSTALL@ -m 0644 $(srcdir)/$${file} $(DESTDIR)$(DEVHELP_DIR) ; \
+ done
15 years, 10 months
[libvirt] [PATCH] Fix devhelp build
by john.levon@sun.com
# HG changeset patch
# User John Levon <john.levon(a)sun.com>
# Date 1231946129 28800
# Node ID c08132809fb6e060b1301e97954a1b0ababb384c
# Parent 52dcd17a9fd4bf4a6171386f083d235eebd5aa23
Fix devhelp build
For devhelp to actually be created during a build, we need to explicitly
depend on the generated files.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/docs/devhelp/Makefile.am b/docs/devhelp/Makefile.am
--- a/docs/devhelp/Makefile.am
+++ b/docs/devhelp/Makefile.am
@@ -20,7 +20,7 @@ libvirt.devhelp $(HTML_FILES): $(srcdir)
-@(if [ -x $(XSLTPROC) ] ; then \
$(XSLTPROC) --nonet -o libvirt.devhelp $(srcdir)/devhelp.xsl $(top_srcdir)/docs/libvirt-api.xml ; fi );
-install-data-local:
+install-data-local: libvirt.devhelp $(HTML_FILES)
$(mkinstalldirs) $(DESTDIR)$(DEVHELP_DIR)
-@INSTALL@ -m 0644 libvirt.devhelp $(DESTDIR)$(DEVHELP_DIR)
-@INSTALL@ -m 0644 $(HTML_FILES) $(DESTDIR)$(DEVHELP_DIR)
15 years, 10 months