[libvirt] libvirt-php login issue to ESXi
by Koen Calliauw
Hi all,
I've started playing with libvirt-php yesterday and with the help of Michal
Novotny got it running quite painlessly. However, the login from PHP to my
testing ESXi server seems to be failing. I've wiresharked the HTTP traffic
with a virsh -c (which works) and compared that to the traffic I see when
using the libvirt-php extension, here's the difference I see (mind the
username)
Not working (libvirt-php)
<Login xmlns="urn:vim25"><_this xmlns="urn:vim25"
xsi:type="ManagedObjectReference"
type="SessionManager">ha-sessionmgr</_this><userName xmlns="urn:vim25"
xsi:type="xsd:string">root8.</userName><password xmlns="urn:vim25"
xsi:type="xsd:string">fakepass</password></Login>
Working (virsh -c)
<Login xmlns="urn:vim25"><_this xmlns="urn:vim25"
xsi:type="ManagedObjectReference"
type="SessionManager">ha-sessionmgr</_this><userName xmlns="urn:vim25"
xsi:type="xsd:string">root</userName><password xmlns="urn:vim25"
xsi:type="xsd:string">fakepass</password></Login>
So for some reason something gets appended (8.) or encoded wrong or
something when I use the PHP extension. This is the testing code I run:
<?php
$credentials =
array(VIR_CRED_AUTHNAME=>'root',VIR_CRED_PASSPHRASE=>'fakepass');
$conn = libvirt_connect("esx://10.9.0.2?transport=http", FALSE,
$credentials);
if($conn) {
print_r(libvirt_connect_get_hypervisor($conn));
} else {
echo "Connection failed: ".libvirt_get_last_error();
}
Any help with this issue would be greatly appreciated. Thanks!
Best regards,
Koen Calliauw
13 years, 6 months
[libvirt] [PATCH] virDomainEventCallbackListAddID: allow different domains to register lifecycle events
by boettcher@tudos.org
Hello,
I had trouble of registering an VIR_DOMAIN_EVENT_ID_LIFECYLCE event for
different domains separately.
First I invoke [0] with one domain, and later with another one. For the
second call the operation will be denied by
"libvir: error : internal error event callback already tracked".
I assume this should be possible for different domains to register
LIFECYLCE handler separately. In that case please consider the attached
patch.
Thanks,
Alex B.
[0]
virConnectDomainEventRegisterAny(
conn, domX, VIR_DOM_EVENT_ID_LIFECYLCE,
VIR_DOMAIN_EVENT_CALLBACK(myDomainEventCallback2),
strdup("callback 2"), myFreeFunc);
13 years, 6 months
[libvirt] [PATCH] screenshot: Set access rights to temporary file
by Michal Privoznik
Although we create a temporary file, it is owned by root:root and have
rights 0600. In case qemu does not run under root, it is unable to write
to that file and thus we transfer 0B sized file.
---
src/qemu/qemu_driver.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8b65c26..562ec42 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2729,6 +2729,8 @@ qemuDomainScreenshot(virDomainPtr dom,
goto endjob;
}
+ virSecurityManagerSetSavedStateLabel(qemu_driver->securityManager, vm, tmp);
+
qemuDomainObjEnterMonitor(vm);
if (qemuMonitorScreendump(priv->mon, tmp) < 0) {
qemuDomainObjExitMonitor(vm);
--
1.7.5.rc3
13 years, 6 months
[libvirt] [PATCH] dnsmasq: Fix errno handling and don't unlink non-existing files
by Matthias Bolte
addnhostsSave and hostsfileSave expect < 0 return value on error from
addnhostsWrite and hostsfileWrite but then pass err instead of -err
to virReportSystemError that expects an errno value.
Also addnhostsWrite returns -ENOMEM and errno, change this to -errno.
addnhostsWrite and hostsfileWrite tried to unlink the tempfile after
renaming it, making both fail on the final step. Remove the unnecessary
unlink calls.
---
src/util/dnsmasq.c | 44 +++++++++++++++-----------------------------
1 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
index 5baa34f..aadca10 100644
--- a/src/util/dnsmasq.c
+++ b/src/util/dnsmasq.c
@@ -185,14 +185,14 @@ addnhostsWrite(const char *path,
if (!(f = fopen(tmp, "w"))) {
istmp = false;
if (!(f = fopen(path, "w"))) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
}
for (i = 0; i < nhosts; i++) {
if (fputs(hosts[i].ip, f) == EOF || fputc('\t', f) == EOF) {
- rc = errno;
+ rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
@@ -203,7 +203,7 @@ addnhostsWrite(const char *path,
for (ii = 0; ii < hosts[i].nhostnames; ii++) {
if (fputs(hosts[i].hostnames[ii], f) == EOF || fputc('\t', f) == EOF) {
- rc = errno;
+ rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
@@ -214,7 +214,7 @@ addnhostsWrite(const char *path,
}
if (fputc('\n', f) == EOF) {
- rc = errno;
+ rc = -errno;
VIR_FORCE_FCLOSE(f);
if (istmp)
@@ -225,21 +225,14 @@ addnhostsWrite(const char *path,
}
if (VIR_FCLOSE(f) == EOF) {
- rc = errno;
+ rc = -errno;
goto cleanup;
}
- if (istmp) {
- if (rename(tmp, path) < 0) {
- rc = errno;
- unlink(tmp);
- goto cleanup;
- }
-
- if (unlink(tmp) < 0) {
- rc = errno;
- goto cleanup;
- }
+ if (istmp && rename(tmp, path) < 0) {
+ rc = -errno;
+ unlink(tmp);
+ goto cleanup;
}
cleanup:
@@ -255,7 +248,7 @@ addnhostsSave(dnsmasqAddnHostsfile *addnhostsfile)
addnhostsfile->nhosts);
if (err < 0) {
- virReportSystemError(err, _("cannot write config file '%s'"),
+ virReportSystemError(-err, _("cannot write config file '%s'"),
addnhostsfile->path);
return -1;
}
@@ -402,17 +395,10 @@ hostsfileWrite(const char *path,
goto cleanup;
}
- if (istmp) {
- if (rename(tmp, path) < 0) {
- rc = -errno;
- unlink(tmp);
- goto cleanup;
- }
-
- if (unlink(tmp) < 0) {
- rc = -errno;
- goto cleanup;
- }
+ if (istmp && rename(tmp, path) < 0) {
+ rc = -errno;
+ unlink(tmp);
+ goto cleanup;
}
cleanup:
@@ -428,7 +414,7 @@ hostsfileSave(dnsmasqHostsfile *hostsfile)
hostsfile->nhosts);
if (err < 0) {
- virReportSystemError(err, _("cannot write config file '%s'"),
+ virReportSystemError(-err, _("cannot write config file '%s'"),
hostsfile->path);
return -1;
}
--
1.7.0.4
13 years, 6 months
[libvirt] [PATCH 0/9] Misc bug fixes to new RPC code
by Daniel P. Berrange
This is a series of bug fixes to the new RPC code I have done
since I posted the original series, which is now merged.
Most of these fixes relate to handling of I/O streams.
Patches 1 and 9 also impacted the original code prior to the
RPC rewrite, and should be backported by people maintaining
old branches
13 years, 6 months
[libvirt] [PATCH] maint: improve makefile whitespace
by Eric Blake
None of these instances cause any semantic differences, but
consistency is nice.
* src/Makefile.am: Replace leading spaces with tabs.
---
Pushing under the trivial rule.
src/Makefile.am | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 7fbbb3f..8f99cc2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -299,13 +299,13 @@ VMWARE_DRIVER_SOURCES = \
vmware/vmware_conf.c vmware/vmware_conf.h
VBOX_DRIVER_SOURCES = \
- vbox/vbox_glue.c vbox/vbox_glue.h \
- vbox/vbox_driver.c vbox/vbox_driver.h \
- vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \
- vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \
- vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
- vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h \
- vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h
+ vbox/vbox_glue.c vbox/vbox_glue.h \
+ vbox/vbox_driver.c vbox/vbox_driver.h \
+ vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \
+ vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \
+ vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
+ vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h \
+ vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h
VBOX_DRIVER_EXTRA_DIST = \
vbox/vbox_tmpl.c vbox/README \
@@ -576,7 +576,7 @@ endif WITH_REMOTE
%protocol.h: %protocol.x $(srcdir)/rpc/genprotocol.pl
$(AM_V_GEN)perl -w $(srcdir)/rpc/genprotocol.pl $(RPCGEN) -h \
- $< $@
+ $< $@
if WITH_XEN
if WITH_DRIVER_MODULES
@@ -1144,8 +1144,8 @@ libvirt_qemu.def: $(srcdir)/libvirt_qemu.syms
# Empty source list - it merely links a bunch of convenience libs together
libvirt_la_SOURCES =
libvirt_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_SYMBOL_FILE) \
- -version-info $(LIBVIRT_VERSION_INFO) \
- $(AM_LDFLAGS) \
+ -version-info $(LIBVIRT_VERSION_INFO) \
+ $(AM_LDFLAGS) \
$(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS)
libvirt_la_BUILT_LIBADD += ../gnulib/lib/libgnu.la
libvirt_la_LIBADD += $(LIBXML_LIBS) \
@@ -1178,8 +1178,8 @@ libvirt_test_la_CFLAGS = $(AM_CFLAGS)
libvirt_qemu_la_SOURCES = libvirt-qemu.c
libvirt_qemu_la_LDFLAGS = $(VERSION_SCRIPT_FLAGS)$(LIBVIRT_QEMU_SYMBOL_FILE) \
- -version-info $(LIBVIRT_VERSION_INFO) \
- $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS) \
+ -version-info $(LIBVIRT_VERSION_INFO) \
+ $(CYGWIN_EXTRA_LDFLAGS) $(MINGW_EXTRA_LDFLAGS) \
$(AM_LDFLAGS)
libvirt_qemu_la_CFLAGS = $(AM_CFLAGS)
libvirt_qemu_la_LIBADD = libvirt.la $(CYGWIN_EXTRA_LIBADD)
@@ -1407,7 +1407,7 @@ if WITH_NETWORK
$(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/default.xml && \
rm $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/default.xml.t; }
test -e $(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart/default.xml || \
- ln -s ../default.xml \
+ ln -s ../default.xml \
$(DESTDIR)$(sysconfdir)/libvirt/qemu/networks/autostart/default.xml
endif
--
1.7.4.4
13 years, 6 months
[libvirt] [PATCH] tests: Fix memory leak in virnetmessagetest
by Osier Yang
Detected when playing with "make -C tests valgrind".
---
tests/virnetmessagetest.c | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c
index e707b67..61f457c 100644
--- a/tests/virnetmessagetest.c
+++ b/tests/virnetmessagetest.c
@@ -167,6 +167,7 @@ static int testMessagePayloadEncode(const void *args ATTRIBUTE_UNUSED)
{
virNetMessageError err;
static virNetMessage msg;
+ int ret = -1;
static const char expect[] = {
0x00, 0x00, 0x00, 0x74, /* Length */
0x11, 0x22, 0x33, 0x44, /* Program */
@@ -204,19 +205,21 @@ static int testMessagePayloadEncode(const void *args ATTRIBUTE_UNUSED)
err.code = VIR_ERR_INTERNAL_ERROR;
err.domain = VIR_FROM_RPC;
+ err.level = VIR_ERR_ERROR;
+
if (VIR_ALLOC(err.message) < 0)
- return -1;
+ goto cleanup;
*err.message = strdup("Hello World");
- err.level = VIR_ERR_ERROR;
if (VIR_ALLOC(err.str1) < 0)
- return -1;
+ goto cleanup;
*err.str1 = strdup("One");
if (VIR_ALLOC(err.str2) < 0)
- return -1;
+ goto cleanup;
*err.str2 = strdup("Two");
if (VIR_ALLOC(err.str3) < 0)
- return -1;
+ goto cleanup;
*err.str3 = strdup("Three");
+
err.int1 = 1;
err.int2 = 2;
@@ -228,29 +231,39 @@ static int testMessagePayloadEncode(const void *args ATTRIBUTE_UNUSED)
msg.header.status = VIR_NET_ERROR;
if (virNetMessageEncodeHeader(&msg) < 0)
- return -1;
+ goto cleanup;
if (virNetMessageEncodePayload(&msg, (xdrproc_t)xdr_virNetMessageError, &err) < 0)
- return -1;
+ goto cleanup;
if (ARRAY_CARDINALITY(expect) != msg.bufferLength) {
VIR_DEBUG("Expect message length %zu got %zu",
sizeof(expect), msg.bufferLength);
- return -1;
+ goto cleanup;
}
if (msg.bufferOffset != 0) {
VIR_DEBUG("Expect message offset 0 got %zu",
msg.bufferOffset);
- return -1;
+ goto cleanup;
}
if (memcmp(expect, msg.buffer, sizeof(expect)) != 0) {
virtTestDifferenceBin(stderr, expect, msg.buffer, sizeof(expect));
- return -1;
- }
-
- return 0;
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ VIR_FREE(*err.message);
+ VIR_FREE(*err.str1);
+ VIR_FREE(*err.str2);
+ VIR_FREE(*err.str3);
+ VIR_FREE(err.message);
+ VIR_FREE(err.str1);
+ VIR_FREE(err.str2);
+ VIR_FREE(err.str3);
+ return ret;
}
static int testMessagePayloadDecode(const void *args ATTRIBUTE_UNUSED)
--
1.7.1
13 years, 6 months
[libvirt] [PATCH] conf: Fix memory leak in virNetworkDNSDefFormat
by Osier Yang
---
src/conf/network_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index d0860d8..45ddee2 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -945,6 +945,7 @@ virNetworkDNSDefFormat(virBufferPtr buf,
def->hosts[ii].names[j]);
virBufferAsprintf(buf, " </host>\n");
+ VIR_FREE(ip);
}
}
--
1.7.1
13 years, 6 months
[libvirt] [PATCH] network: Don't ignore errors in dnsmasq config file creation
by Matthias Bolte
---
This patch depends on
https://www.redhat.com/archives/libvir-list/2011-June/msg01423.html
src/network/bridge_driver.c | 23 +++++++++++++----------
src/util/dnsmasq.c | 10 ++++------
src/util/dnsmasq.h | 4 ++--
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f48fdcb..f54a966 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -446,7 +446,8 @@ networkBuildDnsmasqHostsfile(dnsmasqContext *dctx,
for (i = 0; i < ipdef->nhosts; i++) {
virNetworkDHCPHostDefPtr host = &(ipdef->hosts[i]);
if ((host->mac) && VIR_SOCKET_HAS_ADDR(&host->ip))
- dnsmasqAddDhcpHost(dctx, host->mac, &host->ip, host->name);
+ if (dnsmasqAddDhcpHost(dctx, host->mac, &host->ip, host->name) < 0)
+ return -1;
}
if (dnsdef) {
@@ -454,7 +455,8 @@ networkBuildDnsmasqHostsfile(dnsmasqContext *dctx,
virNetworkDNSHostsDefPtr host = &(dnsdef->hosts[i]);
if (VIR_SOCKET_HAS_ADDR(&host->ip)) {
for (j = 0; j < host->nnames; j++)
- dnsmasqAddHost(dctx, &host->ip, host->names[j]);
+ if (dnsmasqAddHost(dctx, &host->ip, host->names[j]) < 0)
+ return -1;
}
}
}
@@ -600,14 +602,15 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
if (ipdef->nranges || ipdef->nhosts)
virCommandAddArg(cmd, "--dhcp-no-override");
- if (networkBuildDnsmasqHostsfile(dctx, ipdef, network->def->dns) >= 0) {
- if (dctx->hostsfile->nhosts)
- virCommandAddArgPair(cmd, "--dhcp-hostsfile",
- dctx->hostsfile->path);
- if (dctx->addnhostsfile->nhosts)
- virCommandAddArgPair(cmd, "--addn-hosts",
- dctx->addnhostsfile->path);
- }
+ if (networkBuildDnsmasqHostsfile(dctx, ipdef, network->def->dns) < 0)
+ goto cleanup;
+
+ if (dctx->hostsfile->nhosts)
+ virCommandAddArgPair(cmd, "--dhcp-hostsfile",
+ dctx->hostsfile->path);
+ if (dctx->addnhostsfile->nhosts)
+ virCommandAddArgPair(cmd, "--addn-hosts",
+ dctx->addnhostsfile->path);
if (ipdef->tftproot) {
virCommandAddArgList(cmd, "--enable-tftp",
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
index 4bdbb44..5baa34f 100644
--- a/src/util/dnsmasq.c
+++ b/src/util/dnsmasq.c
@@ -502,14 +502,13 @@ dnsmasqContextFree(dnsmasqContext *ctx)
*
* Add dhcp-host entry.
*/
-void
+int
dnsmasqAddDhcpHost(dnsmasqContext *ctx,
const char *mac,
virSocketAddr *ip,
const char *name)
{
- if (ctx->hostsfile)
- hostsfileAdd(ctx->hostsfile, mac, ip, name);
+ return hostsfileAdd(ctx->hostsfile, mac, ip, name);
}
/*
@@ -521,13 +520,12 @@ dnsmasqAddDhcpHost(dnsmasqContext *ctx,
* Add additional host entry.
*/
-void
+int
dnsmasqAddHost(dnsmasqContext *ctx,
virSocketAddr *ip,
const char *name)
{
- if (ctx->addnhostsfile)
- addnhostsAdd(ctx->addnhostsfile, ip, name);
+ return addnhostsAdd(ctx->addnhostsfile, ip, name);
}
/**
diff --git a/src/util/dnsmasq.h b/src/util/dnsmasq.h
index 62f6f38..d16a54f 100644
--- a/src/util/dnsmasq.h
+++ b/src/util/dnsmasq.h
@@ -68,11 +68,11 @@ typedef struct
dnsmasqContext * dnsmasqContextNew(const char *network_name,
const char *config_dir);
void dnsmasqContextFree(dnsmasqContext *ctx);
-void dnsmasqAddDhcpHost(dnsmasqContext *ctx,
+int dnsmasqAddDhcpHost(dnsmasqContext *ctx,
const char *mac,
virSocketAddr *ip,
const char *name);
-void dnsmasqAddHost(dnsmasqContext *ctx,
+int dnsmasqAddHost(dnsmasqContext *ctx,
virSocketAddr *ip,
const char *name);
int dnsmasqSave(const dnsmasqContext *ctx);
--
1.7.0.4
13 years, 6 months