[libvirt] libvirt generates bad kvm command line
by Harald Dunkel
Hi folks,
using this command sequence
<code>
export VIRSH_DEFAULT_CONNECT_URI=qemu:///system
name=Testing
kvmdir=/export/hdunkel/kvm
hda=$kvmdir/$name/hda.qcow2
iso=/export/isos/debian-testing-amd64-netinst.iso
mkdir -p $kvmdir/$name
qemu-img create -f qcow2 $hda 32G
virt-install --connect ${VIRSH_DEFAULT_CONNECT_URI} \
-n $name -r 1024 -vcpus=1 -f $hda -c $iso \
--network=bridge:br0 --vnc --accelerate -v \
--os-type=linux --os-variant=debianSqueeze
</code>
I get the famous "cdrom boot failure code 0003" error.
The log file shows that libvirt generated this kvm command
line:
<code>
LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \
HOME=/root USER=root LOGNAME=root QEMU_AUDIO_DRV=none \
/usr/bin/kvm -S -M pc -m 1024 -smp 1 -name Testing \
-uuid 3a6b6b3f-84e6-6a21-a51a-2c61cf3914e2 \
-monitor unix:/var/lib/libvirt/qemu/Testing.monitor,server,nowait \
-no-reboot -boot d \
-drive file=/export/hdunkel/kvm/Testing/hda.qcow2,if=virtio,index=0
-drive file=/export/isos/debian-testing-amd64-netinst.iso,if=virtio,media=cdrom,index=1 \
-net nic,macaddr=52:54:00:3e:0b:26,vlan=0,model=virtio,name=virtio.0 \
-net tap,fd=18,vlan=0,name=tap.0 -serial pty -parallel none \
-usb -usbdevice tablet -vnc 127.0.0.1:0 -k en-us -vga cirrus
</code>
If I try this on the command line, then there is the same
0003 error.
If I omit the if=virtio for the cdrom drive, then it boots
the cd without 0003.
Can you reproduce this? Is this a problem with libvirt or with
the kvm module?
Kernel is 2.6.31.5, i.e. kvm 0.88. libvirt is 0.7.2
Any helpful comments would be highly appreciated.
Harri
15 years, 1 month
[libvirt] [PATCH 0/6] test: Implement GetVcpus and PinVcpu
by Cole Robinson
Using the recently committed support for driver specific domain data blobs[1],
carry around VCPU pinning info for running test domains, which enables supporting GetVcpus
and PinVcpu, which makes my life easier when adding support in virt-manager.
[1] http://libvirt.org/git/?p=libvirt.git;a=commit;h=3505790b85da55c16191a9dc...
Cole Robinson (6):
test: Fixes for SetVcpus
test: Break out wrapper for setting up started domain state.
test: Use privateData to track running VM vcpu state
test: Update vcpu runtime info in SetVcpus
test: Implement virDomainGetVcpus
test: Implement virDomainPinVcpu
src/test/test_driver.c | 354 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 337 insertions(+), 17 deletions(-)
15 years, 1 month
[libvirt] [PATCH] storage: conf: Fix memory leak in encryption parsing
by Cole Robinson
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/conf/storage_encryption_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index b97b989..a329622 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -112,6 +112,7 @@ virStorageEncryptionSecretParse(virConnectPtr conn, xmlXPathContextPtr ctxt,
uuidstr);
goto cleanup;
}
+ VIR_FREE(uuidstr);
} else {
virStorageReportError(conn, VIR_ERR_XML_ERROR, "%s",
_("missing volume encryption uuid"));
--
1.6.5.1
15 years, 1 month
[libvirt] [PATCH] Various error reporting fixes
by Cole Robinson
- Don't duplicate SystemError
- Use proper error code in domain_conf
- Fix a broken error call in qemu_conf
- Don't use VIR_ERR_ERROR in security driver (isn't a valid code in this case)
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/conf/domain_conf.c | 2 +-
src/conf/storage_conf.c | 6 +++---
src/qemu/qemu_conf.c | 6 ++----
src/qemu/qemu_driver.c | 2 +-
src/security/security_apparmor.c | 30 +++++++++++++++---------------
src/security/security_driver.c | 2 +-
src/security/security_selinux.c | 10 +++++-----
src/xen/xen_hypervisor.c | 4 +---
tests/cpuset | 2 +-
9 files changed, 30 insertions(+), 34 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ba6b28d..ca141e1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3705,7 +3705,7 @@ virDomainCpuSetParse(virConnectPtr conn, const char **str, char sep,
return (ret);
parse_error:
- virDomainReportError(conn, VIR_ERR_XEN_CALL,
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("topology cpuset syntax error"));
return (-1);
}
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 2924a0d..065cd04 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1593,9 +1593,9 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
char path[PATH_MAX];
if ((err = virFileMakePath(driver->configDir))) {
- virStorageReportError(conn, err,
- _("cannot create config directory %s"),
- driver->configDir);
+ virReportSystemError(conn, err,
+ _("cannot create config directory %s"),
+ driver->configDir);
return -1;
}
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 59873d7..71b3550 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1106,10 +1106,8 @@ int qemudExtractVersion(virConnectPtr conn,
return -1;
if (stat(binary, &sb) < 0) {
- char ebuf[1024];
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Cannot find QEMU binary %s: %s"), binary,
- virStrerror(errno, ebuf, sizeof ebuf));
+ virReportSystemError(conn, errno,
+ _("Cannot find QEMU binary %s"), binary);
return -1;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0470315..e8606c8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1773,7 +1773,7 @@ static int qemuDomainSetHostdevOwnership(virConnectPtr conn,
}
return 0;
#else
- qemudReportError(conn, NULL, NULL, "%s",
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s",
_("unable to set host device ownership on this platform"));
return -1;
#endif
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 16de0f2..6db51cd 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -112,7 +112,7 @@ profile_status_file(const char *str)
if (snprintf(profile, PATH_MAX, "%s/%s", APPARMOR_DIR "/libvirt", str)
> PATH_MAX - 1) {
- virSecurityReportError(NULL, VIR_ERR_ERROR,
+ virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("profile name exceeds maximum length"));
}
@@ -204,7 +204,7 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm,
if (errno == EINTR)
goto rewait;
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("Unexpected exit status from virt-aa-helper "
"%d pid %lu"),
WEXITSTATUS(status), (unsigned long)child);
@@ -265,7 +265,7 @@ use_apparmor(void)
if ((len = readlink("/proc/self/exe", libvirt_daemon,
PATH_MAX - 1)) < 0) {
- virSecurityReportError(NULL, VIR_ERR_ERROR,
+ virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("could not find libvirtd"));
return rc;
}
@@ -289,13 +289,13 @@ AppArmorSecurityDriverProbe(void)
/* see if template file exists */
if (snprintf(template, PATH_MAX, "%s/TEMPLATE",
APPARMOR_DIR "/libvirt") > PATH_MAX - 1) {
- virSecurityReportError(NULL, VIR_ERR_ERROR,
+ virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("template too large"));
return SECURITY_DRIVER_DISABLE;
}
if (!virFileExists(template)) {
- virSecurityReportError(NULL, VIR_ERR_ERROR,
+ virSecurityReportError(NULL, VIR_ERR_INTERNAL_ERROR,
_("template \'%s\' does not exist"), template);
return SECURITY_DRIVER_DISABLE;
}
@@ -326,7 +326,7 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm)
if ((vm->def->seclabel.label) ||
(vm->def->seclabel.model) || (vm->def->seclabel.imagelabel)) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s",
_("security label already defined for VM"));
return rc;
@@ -338,7 +338,7 @@ AppArmorGenSecurityLabel(virConnectPtr conn, virDomainObjPtr vm)
/* if the profile is not already loaded, then load one */
if (profile_loaded(profile_name) < 0) {
if (load_profile(conn, profile_name, vm, NULL) < 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot generate AppArmor profile "
"\'%s\'"), profile_name);
goto clean;
@@ -395,13 +395,13 @@ AppArmorGetSecurityLabel(virConnectPtr conn,
if (virStrcpy(sec->label, profile_name,
VIR_SECURITY_LABEL_BUFLEN) == NULL) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("error copying profile name"));
goto clean;
}
if ((sec->enforcing = profile_status(profile_name, 1)) < 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("error calling profile_status()"));
goto clean;
}
@@ -424,7 +424,7 @@ AppArmorRestoreSecurityLabel(virConnectPtr conn, virDomainObjPtr vm)
if (secdef->imagelabel) {
if ((rc = remove_profile(secdef->label)) != 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("could not remove profile for \'%s\'"),
secdef->label);
}
@@ -450,7 +450,7 @@ AppArmorSetSecurityLabel(virConnectPtr conn,
return rc;
if (STRNEQ(drv->name, secdef->model)) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"\'%s\' model configured for domain, but "
"hypervisor driver is \'%s\'."),
@@ -460,7 +460,7 @@ AppArmorSetSecurityLabel(virConnectPtr conn,
}
if (aa_change_profile(profile_name) < 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("error calling aa_change_profile()"));
goto clean;
}
@@ -490,7 +490,7 @@ AppArmorRestoreSecurityImageLabel(virConnectPtr conn,
/* Update the profile only if it is loaded */
if (profile_loaded(secdef->imagelabel) >= 0) {
if (load_profile(conn, secdef->imagelabel, vm, NULL) < 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot update AppArmor profile "
"\'%s\'"),
secdef->imagelabel);
@@ -520,7 +520,7 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn,
if (secdef->imagelabel) {
/* if the device doesn't exist, error out */
if (!virFileExists(disk->src)) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("\'%s\' does not exist"), disk->src);
return rc;
}
@@ -531,7 +531,7 @@ AppArmorSetSecurityImageLabel(virConnectPtr conn,
/* update the profile only if it is loaded */
if (profile_loaded(secdef->imagelabel) >= 0) {
if (load_profile(conn, secdef->imagelabel, vm, disk) < 0) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot update AppArmor profile "
"\'%s\'"),
secdef->imagelabel);
diff --git a/src/security/security_driver.c b/src/security/security_driver.c
index 43d52b1..4e6172d 100644
--- a/src/security/security_driver.c
+++ b/src/security/security_driver.c
@@ -123,7 +123,7 @@ virSecurityDriverSetDOI(virConnectPtr conn,
const char *doi)
{
if (strlen(doi) >= VIR_SECURITY_DOI_BUFLEN) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("%s: DOI \'%s\' is "
"longer than the maximum allowed length of %d"),
__func__, doi, VIR_SECURITY_DOI_BUFLEN - 1);
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 6a03af7..0e31077 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -189,13 +189,13 @@ SELinuxGenSecurityLabel(virConnectPtr conn,
vm->def->seclabel.label = SELinuxGenNewContext(default_domain_context, mcs);
if (! vm->def->seclabel.label) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot generate selinux context for %s"), mcs);
goto err;
}
vm->def->seclabel.imagelabel = SELinuxGenNewContext(default_image_context, mcs);
if (! vm->def->seclabel.imagelabel) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot generate selinux context for %s"), mcs);
goto err;
}
@@ -285,9 +285,9 @@ SELinuxGetSecurityLabel(virConnectPtr conn,
}
if (strlen((char *) ctx) >= VIR_SECURITY_LABEL_BUFLEN) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("security label exceeds "
- "maximum lenth: %d"),
+ "maximum length: %d"),
VIR_SECURITY_LABEL_BUFLEN - 1);
return -1;
}
@@ -647,7 +647,7 @@ SELinuxSetSecurityLabel(virConnectPtr conn,
int i;
if (!STREQ(drv->name, secdef->model)) {
- virSecurityReportError(conn, VIR_ERR_ERROR,
+ virSecurityReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("security label driver mismatch: "
"'%s' model configured for domain, but "
"hypervisor driver is '%s'."),
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 3aa3c30..e107d1e 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2298,9 +2298,7 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode)
if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 ||
pread(fd, ®s, sizeof(regs), 0) != sizeof(regs)) {
- char ebuf[1024];
- virXenError(conn, VIR_ERR_SYSTEM_ERROR,
- "couldn't read CPU flags: %s", virStrerror(errno, ebuf, sizeof ebuf));
+ virReportSystemError(conn, errno, "%s", _("could not read CPU flags"));
goto out;
}
diff --git a/tests/cpuset b/tests/cpuset
index 9f43269..89c19e0 100755
--- a/tests/cpuset
+++ b/tests/cpuset
@@ -41,7 +41,7 @@ sed "s/vcpu>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1
$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
cat <<\EOF > exp || fail=1
error: Failed to define domain from xml-invalid
-error: failed Xen syscall topology cpuset syntax error
+error: internal error topology cpuset syntax error
EOF
compare exp out || fail=1
--
1.6.5.1
15 years, 1 month
[libvirt] [PATCH v2] Improve error reporting for virConnectGetHostname calls
by Cole Robinson
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.
Changes from v1:
Drop the driver wrappers around virGetHostname. This means we still need
to keep the new conn argument to virGetHostname, but I think it's worth
it.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
daemon/libvirtd.c | 7 +++----
src/lxc/lxc_driver.c | 16 +---------------
src/qemu/qemu_driver.c | 22 ++--------------------
src/test/test_driver.c | 16 +---------------
src/uml/uml_driver.c | 17 +----------------
src/util/util.c | 18 +++++++++++++++---
src/util/util.h | 2 +-
src/vbox/vbox_tmpl.c | 16 +---------------
src/xen/xen_driver.c | 20 +-------------------
src/xen/xend_internal.c | 6 ++----
tools/virsh.c | 2 +-
11 files changed, 29 insertions(+), 113 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 0615cd2..322a320 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -993,11 +993,10 @@ static int qemudNetworkInit(struct qemud_server *server) {
if (!mdns_name) {
char groupname[64], *localhost, *tmp;
/* Extract the host part of the potentially FQDN */
- localhost = virGetHostname();
- if (localhost == NULL) {
- virReportOOMError(NULL);
+ localhost = virGetHostname(NULL);
+ if (localhost == NULL)
goto cleanup;
- }
+
if ((tmp = strchr(localhost, '.')))
*tmp = '\0';
snprintf(groupname, sizeof(groupname)-1, "Virtualization Host %s", localhost);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 47e59f6..05fc48d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2027,20 +2027,6 @@ cleanup:
return ret;
}
-static char *lxcGetHostname (virConnectPtr conn)
-{
- char *result;
-
- result = virGetHostname();
- if (result == NULL) {
- virReportSystemError (conn, errno,
- "%s", _("failed to determine host name"));
- return NULL;
- }
- /* Caller frees this string. */
- return result;
-}
-
static int lxcFreezeContainer(lxc_driver_t *driver, virDomainObjPtr vm)
{
int timeout = 1000; /* In milliseconds */
@@ -2258,7 +2244,7 @@ static virDriver lxcDriver = {
NULL, /* supports_feature */
NULL, /* type */
lxcVersion, /* version */
- lxcGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
NULL, /* getMaxVcpus */
nodeGetInfo, /* nodeGetInfo */
lxcGetCapabilities, /* getCapabilities */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 437a1b4..0470315 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2610,21 +2610,6 @@ cleanup:
return ret;
}
-static char *
-qemudGetHostname (virConnectPtr conn)
-{
- char *result;
-
- result = virGetHostname();
- if (result == NULL) {
- virReportSystemError (conn, errno,
- "%s", _("failed to determine host name"));
- return NULL;
- }
- /* Caller frees this string. */
- return result;
-}
-
static int qemudListDomains(virConnectPtr conn, int *ids, int nids) {
struct qemud_driver *driver = conn->privateData;
int n;
@@ -6248,11 +6233,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
/* Get hostname */
- if ((hostname = virGetHostname()) == NULL) {
- virReportSystemError (dconn, errno,
- "%s", _("failed to determine host name"));
+ if ((hostname = virGetHostname(dconn)) == NULL)
goto cleanup;
- }
/* XXX this really should have been a properly well-formed
* URI, but we can't add in tcp:// now without breaking
@@ -7084,7 +7066,7 @@ static virDriver qemuDriver = {
qemudSupportsFeature, /* supports_feature */
qemudGetType, /* type */
qemudGetVersion, /* version */
- qemudGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
qemudGetMaxVCPUs, /* getMaxVcpus */
nodeGetInfo, /* nodeGetInfo */
qemudGetCapabilities, /* getCapabilities */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7e19072..31b5ad3 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1023,20 +1023,6 @@ static int testGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED,
return (0);
}
-static char *testGetHostname (virConnectPtr conn)
-{
- char *result;
-
- result = virGetHostname();
- if (result == NULL) {
- virReportSystemError(conn, errno,
- "%s", _("cannot lookup hostname"));
- return NULL;
- }
- /* Caller frees this string. */
- return result;
-}
-
static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
const char *type ATTRIBUTE_UNUSED)
{
@@ -4674,7 +4660,7 @@ static virDriver testDriver = {
NULL, /* supports_feature */
NULL, /* type */
testGetVersion, /* version */
- testGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
testGetMaxVCPUs, /* getMaxVcpus */
testNodeGetInfo, /* nodeGetInfo */
testGetCapabilities, /* getCapabilities */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index fac3c4c..2455b92 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1146,21 +1146,6 @@ cleanup:
return ret;
}
-static char *
-umlGetHostname (virConnectPtr conn)
-{
- char *result;
-
- result = virGetHostname();
- if (result == NULL) {
- virReportSystemError(conn, errno,
- "%s", _("cannot lookup hostname"));
- return NULL;
- }
- /* Caller frees this string. */
- return result;
-}
-
static int umlListDomains(virConnectPtr conn, int *ids, int nids) {
struct uml_driver *driver = conn->privateData;
int n;
@@ -1790,7 +1775,7 @@ static virDriver umlDriver = {
NULL, /* supports_feature */
umlGetType, /* type */
umlGetVersion, /* version */
- umlGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
NULL, /* getMaxVcpus */
nodeGetInfo, /* nodeGetInfo */
umlGetCapabilities, /* getCapabilities */
diff --git a/src/util/util.c b/src/util/util.c
index 08070da..853d3a0 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1805,30 +1805,42 @@ int virDiskNameToIndex(const char *name) {
#define AI_CANONIDN 0
#endif
-char *virGetHostname(void)
+char *virGetHostname(virConnectPtr conn)
{
int r;
char hostname[HOST_NAME_MAX+1], *result;
struct addrinfo hints, *info;
r = gethostname (hostname, sizeof(hostname));
- if (r == -1)
+ if (r == -1) {
+ virReportSystemError (conn, errno,
+ "%s", _("failed to determine host name"));
return NULL;
+ }
NUL_TERMINATE(hostname);
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME|AI_CANONIDN;
hints.ai_family = AF_UNSPEC;
r = getaddrinfo(hostname, NULL, &hints, &info);
- if (r != 0)
+ if (r != 0) {
+ ReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("getaddrinfo failed for '%s': %s"),
+ hostname, gai_strerror(r));
return NULL;
+ }
if (info->ai_canonname == NULL) {
+ ReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("could not determine canonical host name"));
freeaddrinfo(info);
return NULL;
}
/* Caller frees this string. */
result = strdup (info->ai_canonname);
+ if (!result)
+ virReportOOMError(conn);
+
freeaddrinfo(info);
return result;
}
diff --git a/src/util/util.h b/src/util/util.h
index 3ef26e6..f4e395e 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -222,7 +222,7 @@ static inline int getuid (void) { return 0; }
static inline int getgid (void) { return 0; }
#endif
-char *virGetHostname(void);
+char *virGetHostname(virConnectPtr conn);
int virKillProcess(pid_t pid, int sig);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index aecda23..c6305ac 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -591,20 +591,6 @@ static int vboxGetVersion(virConnectPtr conn, unsigned long *version) {
return 0;
}
-static char *vboxGetHostname(virConnectPtr conn) {
- char *hostname;
-
- /* the return string should be freed by caller */
- hostname = virGetHostname();
- if (hostname == NULL) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s",
- "failed to determine host name");
- return NULL;
- }
-
- return hostname;
-}
-
static int vboxGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED) {
vboxGlobalData *data = conn->privateData;
PRUint32 maxCPUCount = 0;
@@ -6402,7 +6388,7 @@ virDriver NAME(Driver) = {
NULL, /* supports_feature */
NULL, /* type */
vboxGetVersion, /* version */
- vboxGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
vboxGetMaxVcpus, /* getMaxVcpus */
nodeGetInfo, /* nodeGetInfo */
vboxGetCapabilities, /* getCapabilities */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index f2744b0..6dc4ac0 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -478,24 +478,6 @@ xenUnifiedGetVersion (virConnectPtr conn, unsigned long *hvVer)
return -1;
}
-/* NB: Even if connected to the proxy, we're still on the
- * same machine.
- */
-static char *
-xenUnifiedGetHostname (virConnectPtr conn)
-{
- char *result;
-
- result = virGetHostname();
- if (result == NULL) {
- virReportSystemError(conn, errno,
- "%s", _("cannot lookup hostname"));
- return NULL;
- }
- /* Caller frees this string. */
- return result;
-}
-
static int
xenUnifiedGetMaxVcpus (virConnectPtr conn, const char *type)
{
@@ -1659,7 +1641,7 @@ static virDriver xenUnifiedDriver = {
xenUnifiedSupportsFeature, /* supports_feature */
xenUnifiedType, /* type */
xenUnifiedGetVersion, /* version */
- xenUnifiedGetHostname, /* getHostname */
+ virGetHostname, /* getHostname */
xenUnifiedGetMaxVcpus, /* getMaxVcpus */
xenUnifiedNodeGetInfo, /* nodeGetInfo */
xenUnifiedGetCapabilities, /* getCapabilities */
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index d3ab019..9080754 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4347,11 +4347,9 @@ xenDaemonDomainMigratePrepare (virConnectPtr dconn,
* deallocates this string.
*/
if (uri_in == NULL) {
- *uri_out = virGetHostname();
- if (*uri_out == NULL) {
- virReportOOMError(dconn);
+ *uri_out = virGetHostname(dconn);
+ if (*uri_out == NULL)
return -1;
- }
}
return 0;
diff --git a/tools/virsh.c b/tools/virsh.c
index 6b93405..3c668da 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -524,7 +524,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom)
char *thatHost = NULL;
char *thisHost = NULL;
- if (!(thisHost = virGetHostname())) {
+ if (!(thisHost = virGetHostname(ctl->conn))) {
vshError(ctl, "%s", _("Failed to get local hostname"));
goto cleanup;
}
--
1.6.5.1
15 years, 1 month
[libvirt] [PATCH] Make monitor type (miimon/arpmon) optional in bond xml.
by Laine Stump
Lack of one of these in the live xml output was causing the parse to fail.
---
src/conf/interface_conf.c | 35 +++++++++++++----------------------
1 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 31af957..31abf12 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -631,13 +631,17 @@ static int
virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
xmlXPathContextPtr ctxt) {
xmlNodePtr node;
- int ret = 0;
+ int ret = -1;
unsigned long tmp;
def->data.bond.mode = virInterfaceDefParseBondMode(conn, ctxt);
if (def->data.bond.mode < 0)
goto error;
+ ret = virInterfaceDefParseBondItfs(conn, def, ctxt);
+ if (ret != 0)
+ goto error;
+
node = virXPathNode(conn, "./miimon[1]", ctxt);
if (node != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII;
@@ -669,15 +673,13 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
}
def->data.bond.carrier = virInterfaceDefParseBondMiiCarrier(conn, ctxt);
- if (def->data.bond.carrier < 0)
+ if (def->data.bond.carrier < 0) {
+ ret = -1;
goto error;
+ }
- ret = virInterfaceDefParseBondItfs(conn, def, ctxt);
+ } else if ((node = virXPathNode(conn, "./arpmon[1]", ctxt)) != NULL) {
- goto done;
- }
- node = virXPathNode(conn, "./arpmon[1]", ctxt);
- if (node != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP;
ret = virXPathULong(conn, "string(./arpmon/@interval)", ctxt, &tmp);
@@ -693,23 +695,17 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
if (def->data.bond.target == NULL) {
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
"%s", _("bond interface arpmon target missing"));
+ ret = -1;
goto error;
}
def->data.bond.validate = virInterfaceDefParseBondArpValid(conn, ctxt);
- if (def->data.bond.validate < 0)
+ if (def->data.bond.validate < 0) {
+ ret = -1;
goto error;
-
- ret = virInterfaceDefParseBondItfs(conn, def, ctxt);
-
- goto done;
+ }
}
-
- virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
- "%s", _("bond interface need miimon or arpmon element"));
error:
- ret = -1;
-done:
return(ret);
}
@@ -1109,11 +1105,6 @@ virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf,
else if (def->data.bond.validate == VIR_INTERFACE_BOND_ARP_ALL)
virBufferAddLit(buf, " validate='all'");
virBufferAddLit(buf, "/>\n");
- } else {
- virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("bond monitoring type %d unknown"),
- def->data.bond.monit);
- return(-1);
}
for (i = 0;i < def->data.bond.nbItf;i++) {
if (virInterfaceBareDevDefFormat(conn, buf, def->data.bond.itf[i]) < 0)
--
1.6.5.15.gc274d
15 years, 1 month
[libvirt] [PATCH 0/3] IPv6 / multi address / report live config in virInterface
by laine@laine.org
This is the 2nd iteration of this patchset incorporating danpb's
suggestions. Along with a couple other minor things, the type attribute
is again a required attribute, and netcf support will be omitted in
the build unless you have netcf-devel-0.1.3 or greater. Since there is
no netcf-devel-0.1.3 yet, I tested this by changing the appropriate
strings to 0.1.2. 0.1.3 will be released "soon" (I want to try and get
IPv6 address reporting in before lutter cuts another release). I just
wanted to get the patches to the list early to get some visual review
in case I screwed up anything new ;-)
Note that (unless you're building/installing netcf from the head of
git) if you try to fake out the version of netcf yourself you'll get
runtime errors from virInterfaceGetXMLDesc (iface-dumpxml) due to
there being no "type" attribute in the interface xml.
15 years, 1 month
[libvirt] [PATCH] give up python interpreter lock before calling cb
by Dan Kenigsberg
suggested by danpb on irc
---
python/libvirt-override.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 5d24fd2..53e36c0 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -2355,7 +2355,9 @@ libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED,
opaque = (void *) PyvirVoidPtr_Get(py_opaque);
if(cb)
+ LIBVIRT_BEGIN_ALLOW_THREADS
cb (watch, fd, event, opaque);
+ LIBVIRT_END_ALLOW_THREADS
return VIR_PY_INT_SUCCESS;
}
@@ -2379,7 +2381,9 @@ libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED,
cb = (virEventTimeoutCallback) PyvirEventTimeoutCallback_Get(py_f);
opaque = (void *) PyvirVoidPtr_Get(py_opaque);
if(cb)
+ LIBVIRT_BEGIN_ALLOW_THREADS
cb (timer, opaque);
+ LIBVIRT_END_ALLOW_THREADS
return VIR_PY_INT_SUCCESS;
}
--
1.6.2.5
15 years, 1 month
[libvirt] The 0.7.3 release schedule
by Daniel Veillard
Well, clearly we can't keep up with the current plan, we should be in
freeze right now and there is an awful lot of patches on the list
waiting for review and push. Let's try to push everything by this
week-end and have next week as the testing and freeze time. Maybe we can
squeeze everything in time, that would allow the release by the
Friday 13th (unless we want to avoid that ;-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
15 years, 1 month