[libvirt] [PATCH V2 2/6] libxl: add default firmwares to driver config object
by Jim Fehlig
Prefer firmwares specified via --with-loader-nvram configure
option. If none are specified, use the Xen-provided default
firmwares found in LIBXL_FIRMWARE_DIR.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 21 +++++++++++++++++++++
src/libxl/libxl_conf.h | 4 ++++
2 files changed, 25 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index a64b4c1..b347b8c 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -104,6 +104,7 @@ libxlDriverConfigDispose(void *obj)
VIR_FREE(cfg->saveDir);
VIR_FREE(cfg->autoDumpDir);
VIR_FREE(cfg->lockManagerName);
+ virFirmwareFreeList(cfg->firmwares, cfg->nfirmwares);
}
@@ -1777,6 +1778,26 @@ libxlDriverConfigNew(void)
goto error;
}
+#ifdef DEFAULT_LOADER_NVRAM
+ if (virFirmwareParseList(DEFAULT_LOADER_NVRAM,
+ &cfg->firmwares,
+ &cfg->nfirmwares) < 0)
+ goto error;
+
+#else
+ if (VIR_ALLOC_N(cfg->firmwares, 2) < 0)
+ goto error;
+ cfg->nfirmwares = 2;
+ if (VIR_ALLOC(cfg->firmwares[0]) < 0 || VIR_ALLOC(cfg->firmwares[1]) < 0)
+ goto error;
+
+ if (VIR_STRDUP(cfg->firmwares[0]->name,
+ LIBXL_FIRMWARE_DIR "/hvmloader") < 0 ||
+ VIR_STRDUP(cfg->firmwares[1]->name,
+ LIBXL_FIRMWARE_DIR "/ovmf.bin") < 0)
+ goto error;
+#endif
+
return cfg;
error:
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index c5b9429..e55717a 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -39,6 +39,7 @@
# include "virchrdev.h"
# include "virhostdev.h"
# include "locking/lock_manager.h"
+# include "virfirmware.h"
# define LIBXL_DRIVER_NAME "xenlight"
# define LIBXL_VNC_PORT_MIN 5900
@@ -107,6 +108,9 @@ struct _libxlDriverConfig {
char *libDir;
char *saveDir;
char *autoDumpDir;
+
+ virFirmwarePtr *firmwares;
+ size_t nfirmwares;
};
--
2.1.4
8 years, 6 months
[libvirt] [PATCH v2] virsh: domdisplay: if listen is 0.0.0.0 or [::] print address from URI
by Pavel Hrdina
Currently if a guest has listen address 0.0.0.0 or [::] and you run
"virsh domdisplay $domain" you always get "spice://localhost:$port".
We want to print better address if someone is connected from a different
computer using "virsh -c qemu+ssh://some.host/system". This patch fixes the
behavior of virsh to print in this case "spice://some.host:$port".
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1332446
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
changes in v2:
- use virConnectPtr instead connname to properly handle aliases and
default uri
tools/virsh-domain.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 8d7ff61..6f8edbb 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -57,6 +57,7 @@
#include "virtypedparam.h"
#include "virxml.h"
#include "virsh-nodedev.h"
+#include "viruri.h"
/* Gnulib doesn't guarantee SA_SIGINFO support. */
#ifndef SA_SIGINFO
@@ -10617,6 +10618,30 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
VIR_FREE(xpath);
}
+ /* If listen_addr is 0.0.0.0 or [::] we should try to parse URI and set
+ * listen_addr based on current URI. */
+ if (listen_addr) {
+ if (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
+ virSocketAddrIsWildcard(&addr)) {
+
+ virConnectPtr conn = ((virshControlPtr)(ctl->privData))->conn;
+ char *uriStr = virConnectGetURI(conn);
+ virURIPtr uri = NULL;
+
+ if (uriStr) {
+ uri = virURIParse(uriStr);
+ VIR_FREE(uriStr);
+ }
+
+ /* It's safe to free the listen_addr even if parsing of URI
+ * fails, if there is no listen_addr we will print "localhost". */
+ VIR_FREE(listen_addr);
+
+ if (uri && VIR_STRDUP(listen_addr, uri->server) < 0)
+ goto cleanup;
+ }
+ }
+
/* We can query this info for all the graphics types since we'll
* get nothing for the unsupported ones (just rdp for now).
* Also the parameter '--include-password' was already taken
@@ -10638,9 +10663,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
virBufferAsprintf(&buf, ":%s@", passwd);
/* Then host name or IP */
- if (!listen_addr ||
- (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 &&
- virSocketAddrIsWildcard(&addr)))
+ if (!listen_addr)
virBufferAddLit(&buf, "localhost");
else if (strchr(listen_addr, ':'))
virBufferAsprintf(&buf, "[%s]", listen_addr);
--
2.8.3
8 years, 6 months
[libvirt] [PATCH v2 00/19] Drop virt prefix from tests.
by Tomáš Ryšavý
Replacig virt prefix with vir prefix in tests. It was suggested on wikipage:
http://wiki.libvirt.org/page/BiteSizedTasks#Rename_test_suite_routines_fr...
Tomáš Ryšavý (19):
tests: Rename virtTestRun to virTestRun.
Rename virtTestDifference to virTestDifference.
Rename virtTestLoadFile to virTestLoadFile.
tests: Rename virtTestCompareToFile to virTestCompareToFile.
Rename virtTestDifferenceFull to virTestDifferenceFull.
tests: Rename virtTestClearCommandPath to virTestClearCommandPath.
tests: Rename virtTest00MActive to virTest00MActive.
tests: Rename virtTestCounterReset to virTestCounterReset.
tests: Rename virtTestLogContentAndReset to virTestLogContentAndReset.
tests: Rename virtTestUseTerminalColors to virTestUseTerminalColors.
tests: Rename virtTestQuiesceLibvirtErrors to
virTestQuiesceLibvirtErrors.
tests: Rename virtTestDifferenceFullNoRegenerate.
tests: Rename virtTestDifferenceFullInternal to
virTestDifferenceFullInternal.
tests: Rename virtTestCaptureProgramExecChild to
virTestCaptureProgramExecChild.
tests: Rename virtTestDifferenceBin to virTestDifferenceBin.
tests: Rename virtTestCaptureProgramOutput to
virTestCaptureProgramOutput.
tests: Rename virtTestCounterNext to virTestCounterNext.
tests: Rename virtTestErrorFuncQuiet to virTestErrorFuncQuiet.
tests: Rename virtTestMain to virTestMain.
tests/bhyvexml2argvtest.c | 8 +--
tests/bhyvexml2xmltest.c | 2 +-
tests/commandtest.c | 20 +++---
tests/cputest.c | 8 +--
tests/domaincapstest.c | 6 +-
tests/domainconftest.c | 2 +-
tests/domainsnapshotxml2xmltest.c | 10 +--
tests/esxutilstest.c | 14 ++--
tests/eventtest.c | 2 +-
tests/fchosttest.c | 10 +--
tests/fdstreamtest.c | 8 +--
tests/genericxml2xmltest.c | 4 +-
tests/interfacexml2xmltest.c | 8 +--
tests/jsontest.c | 8 +--
tests/libvirtdconftest.c | 2 +-
tests/lxcconf2xmltest.c | 10 +--
tests/lxcxml2xmltest.c | 4 +-
tests/metadatatest.c | 12 ++--
tests/networkxml2conftest.c | 6 +-
tests/networkxml2firewalltest.c | 8 +--
tests/networkxml2xmltest.c | 6 +-
tests/networkxml2xmlupdatetest.c | 8 +--
tests/nodedevxml2xmltest.c | 8 +--
tests/nodeinfotest.c | 8 +--
tests/nsstest.c | 2 +-
tests/nwfilterebiptablestest.c | 70 +++++++++----------
tests/nwfilterxml2firewalltest.c | 8 +--
tests/nwfilterxml2xmltest.c | 6 +-
tests/objecteventtest.c | 24 +++----
tests/openvzutilstest.c | 6 +-
tests/qemuagenttest.c | 2 +-
tests/qemuargv2xmltest.c | 12 ++--
tests/qemucapabilitiestest.c | 6 +-
tests/qemucaps2xmltest.c | 6 +-
tests/qemucommandutiltest.c | 8 +--
tests/qemuhelptest.c | 8 +--
tests/qemuhotplugtest.c | 14 ++--
tests/qemumonitorjsontest.c | 14 ++--
tests/qemumonitortest.c | 8 +--
tests/qemuxml2argvtest.c | 64 +++++++++---------
tests/qemuxml2xmltest.c | 18 ++---
tests/scsihosttest.c | 8 +--
tests/secretxml2xmltest.c | 6 +-
tests/securityselinuxlabeltest.c | 2 +-
tests/securityselinuxtest.c | 26 +++----
tests/sexpr2xmltest.c | 8 +--
tests/sockettest.c | 76 ++++++++++-----------
tests/storagebackendsheepdogtest.c | 8 +--
tests/storagepoolxml2xmltest.c | 6 +-
tests/storagevolxml2argvtest.c | 6 +-
tests/storagevolxml2xmltest.c | 6 +-
tests/sysinfotest.c | 4 +-
tests/testutils.c | 134 ++++++++++++++++++-------------------
tests/testutils.h | 68 +++++++++----------
tests/utiltest.c | 8 +--
tests/vboxsnapshotxmltest.c | 10 +--
tests/viralloctest.c | 14 ++--
tests/viratomictest.c | 4 +-
tests/virauthconfigtest.c | 16 ++---
tests/virbitmaptest.c | 26 +++----
tests/virbuftest.c | 16 ++---
tests/vircaps2xmltest.c | 6 +-
tests/vircapstest.c | 16 ++---
tests/vircgrouptest.c | 40 +++++------
tests/vircryptotest.c | 4 +-
tests/virdbustest.c | 20 +++---
tests/virdrivermoduletest.c | 8 +--
tests/virendiantest.c | 4 +-
tests/virfiletest.c | 8 +--
tests/virfirewalltest.c | 36 +++++-----
tests/virhashtest.c | 2 +-
tests/virhostdevtest.c | 2 +-
tests/viridentitytest.c | 12 ++--
tests/viriscsitest.c | 10 +--
tests/virkeycodetest.c | 4 +-
tests/virkeyfiletest.c | 2 +-
tests/virkmodtest.c | 6 +-
tests/virlockspacetest.c | 14 ++--
tests/virlogtest.c | 2 +-
tests/virnetdaemontest.c | 6 +-
tests/virnetdevbandwidthtest.c | 12 ++--
tests/virnetdevtest.c | 4 +-
tests/virnetmessagetest.c | 16 ++---
tests/virnetserverclienttest.c | 4 +-
tests/virnetsockettest.c | 32 ++++-----
tests/virnettlscontexttest.c | 4 +-
tests/virnettlssessiontest.c | 58 ++++++++--------
tests/virpcitest.c | 8 +--
tests/virpolkittest.c | 12 ++--
tests/virportallocatortest.c | 8 +--
tests/virrandomtest.c | 2 +-
tests/virrotatingfiletest.c | 26 +++----
tests/virscsitest.c | 4 +-
tests/virshtest.c | 72 ++++++++++----------
tests/virstoragetest.c | 20 +++---
tests/virstringtest.c | 70 +++++++++----------
tests/virsystemdtest.c | 54 +++++++--------
tests/virtimetest.c | 54 +++++++--------
tests/virtypedparamtest.c | 8 +--
tests/viruritest.c | 18 ++---
tests/virusbtest.c | 14 ++--
tests/vmwarevertest.c | 6 +-
tests/vmx2xmltest.c | 8 +--
tests/xencapstest.c | 44 ++++++------
tests/xlconfigtest.c | 14 ++--
tests/xmconfigtest.c | 14 ++--
tests/xml2sexprtest.c | 6 +-
tests/xml2vmxtest.c | 6 +-
108 files changed, 855 insertions(+), 855 deletions(-)
--
2.5.5
8 years, 6 months
[libvirt] [PATCH] virschematest: call va_end even on OOM
by Ján Tomko
Jump to cleanup if virAsprintf fails.
---
tests/virschematest.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/virschematest.c b/tests/virschematest.c
index c173037..f15e2ab 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -117,23 +117,23 @@ testSchemaDir(const char *schema,
}
static int
testSchemaDirs(const char *schema, ...)
{
- virXMLValidatorPtr validator;
+ virXMLValidatorPtr validator = NULL;
va_list args;
int ret = 0;
char *schema_path = NULL;
char *dir_path = NULL;
const char *dir;
va_start(args, schema);
if (virAsprintf(&schema_path, "%s/docs/schemas/%s", abs_topsrcdir, schema) < 0)
- return -1;
+ goto cleanup;
if (!(validator = virXMLValidatorInit(schema_path)))
goto cleanup;
while ((dir = va_arg(args, char *))) {
if (virAsprintf(&dir_path, "%s/%s", abs_srcdir, dir) < 0) {
--
2.7.3
8 years, 6 months
[libvirt] [PATCH v4] node_device: Replace VIR_ERROR with standard vir*Error in state driver init
by Jovanka Gulicoska
---
src/node_device/node_device_hal.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 6ddfad0..2718706 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -641,24 +641,29 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
dbus_error_init(&err);
if (!(sysbus = virDBusGetSystemBus())) {
- VIR_ERROR(_("DBus not available, disabling HAL driver: %s"),
- virGetLastErrorMessage());
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("DBus not available, disabling HAL driver: %s"),
+ virGetLastErrorMessage());
ret = 0;
goto failure;
}
hal_ctx = libhal_ctx_new();
if (hal_ctx == NULL) {
- VIR_ERROR(_("libhal_ctx_new returned NULL"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libhal_ctx_new returned NULL"));
goto failure;
}
if (!libhal_ctx_set_dbus_connection(hal_ctx, sysbus)) {
- VIR_ERROR(_("libhal_ctx_set_dbus_connection failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libhal_ctx_set_dbus_connection failed"));
goto failure;
}
if (!libhal_ctx_init(hal_ctx, &err)) {
- VIR_ERROR(_("libhal_ctx_init failed, haldaemon is probably not running"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libhal_ctx_init failed, haldaemon is probably "
+ "not running"));
/* We don't want to show a fatal error here,
otherwise entire libvirtd shuts down when
hald isn't running */
@@ -683,13 +688,15 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
!libhal_ctx_set_device_lost_capability(hal_ctx, device_cap_lost) ||
!libhal_ctx_set_device_property_modified(hal_ctx, device_prop_modified) ||
!libhal_device_property_watch_all(hal_ctx, &err)) {
- VIR_ERROR(_("setting up HAL callbacks failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("setting up HAL callbacks failed"));
goto failure;
}
udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
if (udi == NULL) {
- VIR_ERROR(_("libhal_get_all_devices failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libhal_get_all_devices failed"));
goto failure;
}
for (i = 0; i < num_devs; i++) {
@@ -702,7 +709,8 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
failure:
if (dbus_error_is_set(&err)) {
- VIR_ERROR(_("%s: %s"), err.name, err.message);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%s: %s"), err.name, err.message);
dbus_error_free(&err);
}
virNodeDeviceObjListFree(&driver->devs);
@@ -753,7 +761,8 @@ nodeStateReload(void)
dbus_error_init(&err);
udi = libhal_get_all_devices(hal_ctx, &num_devs, &err);
if (udi == NULL) {
- VIR_ERROR(_("libhal_get_all_devices failed"));
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("libhal_get_all_devices failed"));
return -1;
}
for (i = 0; i < num_devs; i++) {
--
2.5.5
8 years, 6 months
[libvirt] [PATCH 0/9] LXC: Use virDomainObjGetDefs more
by Ján Tomko
In a few API implementations, we use virDomainLiveConfigHelperMethod
to check the VIR_DOMAIN_AFFECT_* flags (and change the flags variable
to either AFFECT_LIVE or AFFECT_CONFIG if AFFECT_CURRENT was requested)
and optionally give us a pointer to the persistent definition.
This function can also create the persistent definition in vm->newDef
for a live domain if it does not exist yet. This cannot be the case
in LXC driver because we create it unconditionally on domain startup.
By switching to virDomainObjGetDefs we do not need to pass virCaps
and virDomainXMLOption (because the defintion does not need to be copied).
Also, instead of altering the flags, it fills the pointers to live and persistent
definitions depending on which one was requested to be modified,
making the code easier to read for static analyzers.
Ján Tomko (9):
lxc: rename vmdef to persistentDef
Use virDomainObjGetDefs in lxcDomainSetMemoryFlags
Use virDomainObjGetDefs in lxcDomainSetSchedulerParametersFlags
Use virDomainObjGetDefs in lxcDomainGetSchedulerParametersFlags
Use virDomainObjGetDefs in lxcDomainGetMemoryParameters
Use virDomainObjGetDefs in lxcDomainSetBlkioParameters
Use virDomainObjGetDefs in lxcDomainGetBlkioParameters
Export virDomainGetBlkioParametersAssignFromDef
lxc: simplify lxcDomainGetBlkioParameters
src/conf/domain_conf.c | 51 +++++
src/conf/domain_conf.h | 6 +
src/libvirt_private.syms | 1 +
src/lxc/lxc_driver.c | 511 +++++++++--------------------------------------
src/qemu/qemu_driver.c | 59 +-----
5 files changed, 154 insertions(+), 474 deletions(-)
--
2.7.3
8 years, 6 months
[libvirt] [PATCH] virsh-network: Avoid possible NULL deref in cmdNetworkDHCPLeases
by Michal Privoznik
Problem is, localtime_r() returns a pointer to converted time or
NULL in case of an error. But checking the glibc sources, error
will occur iff a NULL has been passed as an either of arguments
the function takes. But GCC fails to see that:
../../tools/virsh-network.c: In function 'cmdNetworkDHCPLeases':
../../tools/virsh-network.c:1370:12: error: potential null pointer dereference [-Werror=null-dereference]
ts = *localtime_r(&expirytime_tmp, &ts);
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-network.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 22ea016..5abcda3 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -1367,7 +1367,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
time_t expirytime_tmp = lease->expirytime;
struct tm ts;
char expirytime[32];
- ts = *localtime_r(&expirytime_tmp, &ts);
+ localtime_r(&expirytime_tmp, &ts);
strftime(expirytime, sizeof(expirytime), "%Y-%m-%d %H:%M:%S", &ts);
if (lease->type == VIR_IP_ADDR_TYPE_IPV4)
--
2.8.3
8 years, 6 months
[libvirt] [PATCHv2 0/5] Speed up schema testing
by Ján Tomko
Instead of spawining a separate xmllint process for every file,
introduce virXMLValidator APIs and use them in a C test file.
Originally, the shell-based schema tests took about 15s in series
(with domainschematest making up for about 13s of that).
Now, all the tests run in series take ~.57 ms.
This reduces total make check time from ~16s to ~8s, making it
more fun to use with git rebase -x.
Ján Tomko (5):
Introduce virXMLValidator structure
Introduce virXMLValidatorFree
Introduce virXMLValidatorInit
Introduce virXMLValidatorValidate
Introduce virschematest
.gitignore | 1 -
src/libvirt_private.syms | 3 +
src/util/virxml.c | 102 ++++++++++++++++------
src/util/virxml.h | 19 +++++
tests/Makefile.am | 28 ++----
tests/capabilityschematest | 9 --
tests/domaincapsschematest | 10 ---
tests/domainschematest | 14 ---
tests/domainsnapshotschematest | 9 --
tests/interfaceschematest | 9 --
tests/networkschematest | 9 --
tests/nodedevschematest | 9 --
tests/nwfilterschematest | 9 --
tests/schematestutils.sh | 47 ----------
tests/secretschematest | 9 --
tests/storagepoolschematest | 9 --
tests/storagevolschematest | 9 --
tests/virschematest.c | 190 +++++++++++++++++++++++++++++++++++++++++
18 files changed, 293 insertions(+), 202 deletions(-)
delete mode 100755 tests/capabilityschematest
delete mode 100755 tests/domaincapsschematest
delete mode 100755 tests/domainschematest
delete mode 100755 tests/domainsnapshotschematest
delete mode 100755 tests/interfaceschematest
delete mode 100755 tests/networkschematest
delete mode 100755 tests/nodedevschematest
delete mode 100755 tests/nwfilterschematest
delete mode 100644 tests/schematestutils.sh
delete mode 100755 tests/secretschematest
delete mode 100755 tests/storagepoolschematest
delete mode 100755 tests/storagevolschematest
create mode 100644 tests/virschematest.c
--
2.7.3
8 years, 6 months