[libvirt] [PATCH] remote_daemon: Log host boot time
by Michal Privoznik
This is not strictly needed, but it makes sure we initialize the
@bootTime global variable. Thing is, in order to validate XATTRs
and prune those set in some previous runs of the host, a
timestamp is recorded in XATTRs. The host boot time was unique
enough so it was chosen as the timestamp value. And to avoid
querying and parsing /proc/uptime every time, the query function
does that only once and stores the boot time in a global
variable. However, the only time the query function is called is
in a child process that does lock files and changes seclabels. So
effectively, we are doing exactly what we wanted to prevent from
happening.
The fix is simple, call the query function whilst the daemon is
initializing.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Since this will be used by security driver only, I was tempted to put
this somewhere under src/security/, but especially because of split
daemon I didn't. Placing this into remote_daemon.c makes sure all
sub-daemons will have the variable initialized and won't suffer the
problem.
src/remote/remote_daemon.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index b400b1dd10..5debb6ce97 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -57,6 +57,7 @@
#include "virgettext.h"
#include "util/virnetdevopenvswitch.h"
#include "virsystemd.h"
+#include "virhostuptime.h"
#include "driver.h"
@@ -1020,6 +1021,7 @@ int main(int argc, char **argv) {
bool implicit_conf = false;
char *run_dir = NULL;
mode_t old_umask;
+ unsigned long long bootTime;
struct option opts[] = {
{ "verbose", no_argument, &verbose, 'v'},
@@ -1151,6 +1153,12 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
+ if (virHostGetBootTime(&bootTime) < 0) {
+ VIR_DEBUG("Unable to get host boot time");
+ } else {
+ VIR_DEBUG("host boot time: %lld", bootTime);
+ }
+
daemonSetupNetDevOpenvswitch(config);
if (daemonSetupAccessManager(config) < 0) {
--
2.24.1
4 years, 11 months
[libvirt] [PATCH] cpu: add CLZERO CPUID support for AMD platforms (libvirt 4.5)
by Ani Sinha
Qemu commit e900135dcfb67 ("i386: Add CPUID bit for CLZERO and XSAVEERPTR")
adds support for CLZERO CPUID bit. This commit extends support for this
bit in libvirt.
This patch is based off of libvirt-4.5 tree.
Signed-off-by: Ani Sinha <ani.sinha(a)nutanix.com>
---
src/cpu/cpu_map.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 088c820..c251cb7 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -431,6 +431,9 @@
<feature name='virt-ssbd'>
<cpuid eax_in='0x80000008' ebx='0x02000000'/>
</feature>
+ <feature name='clzero'>
+ <cpuid eax_in='0x80000008' ebx='0x00000001'/>
+ </feature>
<!-- models -->
<model name='486'>
@@ -1685,6 +1688,7 @@
<feature name='bmi2'/>
<feature name='clflush'/>
<feature name='clflushopt'/>
+ <feature name='clzero'/>
<feature name='cmov'/>
<feature name='cr8legacy'/>
<feature name='cx16'/>
@@ -1756,6 +1760,7 @@
<feature name='bmi2'/>
<feature name='clflush'/>
<feature name='clflushopt'/>
+ <feature name='clzero'/>
<feature name='cmov'/>
<feature name='cr8legacy'/>
<feature name='cx16'/>
--
1.9.4
4 years, 11 months
[libvirt] [PATCH 1/1] qemu: hide details of fake reboot
by Nikolay Shirokovskiy
If we use fake reboot then domain goes thru running->shutdown->running
state changes with shutdown state only for short period of time. At
least this is implementation details leaking into API. And also there is
one real case when this is not convinient. I'm doing a backup with the
help of temporary block snapshot (with the help of qemu's API which is
used in the newly created libvirt's backup API). If guest is shutdowned
I want to continue to backup so I don't kill the process and domain is
in shutdown state. Later when backup is finished I want to destroy qemu
process. So I check if it is in shutdowned state and destroy it if it
is. Now if instead of shutdown domain got fake reboot then I can destroy
process in the middle of fake reboot process.
After shutdown event we also get stop event and now as domain state is
running it will be transitioned to paused state and back to running
later. Though this is not critical for the described case I guess it is
better not to leak these details to user too. So let's leave domain in
running state on stop event if fake reboot is in process.
As we don't know when stop event really arrive let's move resetting flag
after starting CPUs - at this point stop event should be handled.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/qemu/qemu_process.c | 57 ++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 26 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ed8666e9d1..2d37f92724 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -500,6 +500,8 @@ qemuProcessFakeReboot(void *opaque)
goto endjob;
}
+ qemuDomainSetFakeReboot(driver, vm, false);
+
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
VIR_WARN("Unable to save status on vm %s after state change",
vm->def->name);
@@ -525,7 +527,6 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
if (priv->fakeReboot) {
- qemuDomainSetFakeReboot(driver, vm, false);
virObjectRef(vm);
virThread th;
if (virThreadCreate(&th,
@@ -534,6 +535,7 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
vm) < 0) {
VIR_ERROR(_("Failed to create reboot thread, killing domain"));
ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
+ qemuDomainSetFakeReboot(driver, vm, false);
virObjectUnref(vm);
}
} else {
@@ -595,35 +597,37 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon G_GNUC_UNUSED,
goto unlock;
}
- VIR_DEBUG("Transitioned guest %s to shutdown state",
- vm->def->name);
- virDomainObjSetState(vm,
- VIR_DOMAIN_SHUTDOWN,
- VIR_DOMAIN_SHUTDOWN_UNKNOWN);
+ if (!priv->fakeReboot) {
+ VIR_DEBUG("Transitioned guest %s to shutdown state",
+ vm->def->name);
+ virDomainObjSetState(vm,
+ VIR_DOMAIN_SHUTDOWN,
+ VIR_DOMAIN_SHUTDOWN_UNKNOWN);
- switch (guest_initiated) {
- case VIR_TRISTATE_BOOL_YES:
- detail = VIR_DOMAIN_EVENT_SHUTDOWN_GUEST;
- break;
+ switch (guest_initiated) {
+ case VIR_TRISTATE_BOOL_YES:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_GUEST;
+ break;
- case VIR_TRISTATE_BOOL_NO:
- detail = VIR_DOMAIN_EVENT_SHUTDOWN_HOST;
- break;
+ case VIR_TRISTATE_BOOL_NO:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_HOST;
+ break;
- case VIR_TRISTATE_BOOL_ABSENT:
- case VIR_TRISTATE_BOOL_LAST:
- default:
- detail = VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED;
- break;
- }
+ case VIR_TRISTATE_BOOL_ABSENT:
+ case VIR_TRISTATE_BOOL_LAST:
+ default:
+ detail = VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED;
+ break;
+ }
- event = virDomainEventLifecycleNewFromObj(vm,
- VIR_DOMAIN_EVENT_SHUTDOWN,
- detail);
+ event = virDomainEventLifecycleNewFromObj(vm,
+ VIR_DOMAIN_EVENT_SHUTDOWN,
+ detail);
- if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
- VIR_WARN("Unable to save status on vm %s after state change",
- vm->def->name);
+ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) {
+ VIR_WARN("Unable to save status on vm %s after state change",
+ vm->def->name);
+ }
}
if (priv->agent)
@@ -657,7 +661,8 @@ qemuProcessHandleStop(qemuMonitorPtr mon G_GNUC_UNUSED,
reason = priv->pausedReason;
priv->pausedReason = VIR_DOMAIN_PAUSED_UNKNOWN;
- if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING) {
+ if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING &&
+ !priv->fakeReboot) {
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT) {
if (priv->job.current->status == QEMU_DOMAIN_JOB_STATUS_POSTCOPY)
reason = VIR_DOMAIN_PAUSED_POSTCOPY;
--
2.23.0
4 years, 11 months
[libvirt] [PATCH 0/2] Remove VIR_FILE_*_SEPARATOR_*
by Fabiano Fidêncio
Let's use the defines provided by GLib, instead of keeping our own.
Fabiano Fidêncio (2):
util: Use G_DIR_SEPARATOR instead of VIR_FILE_DIR_SEPARATOR
util: Remove VIR_FILE_*_SEPARATOR*
src/util/virfile.c | 2 +-
src/util/virfile.h | 19 -------------------
2 files changed, 1 insertion(+), 20 deletions(-)
--
2.23.0
4 years, 11 months
[libvirt] [PATCH 0/3] Remove unused virFile*() functions
by Fabiano Fidêncio
- virFileSkipRoot() is no longer used since faf2d811f3e9a4;
- virFileIsAbsPath() is no longer used since faf2d811f3e9a4;
- VIR_FILE_IS_DIR_SEPARATOR is no longer used since virFileIsAbsPath has
been dropped;
Fabiano Fidêncio (3):
util: Remove virFileSkipRoot()
util: Remove virFileIsAbsPath()
util: Remove VIR_FILE_IS_DIR_SEPARATOR
src/libvirt_private.syms | 2 --
src/util/virfile.c | 73 ----------------------------------------
src/util/virfile.h | 4 ---
3 files changed, 79 deletions(-)
--
2.23.0
4 years, 11 months
[libvirt] [PATCH] docs: Only distribute sanlock manpage if WITH_SANLOCK
by Cole Robinson
This fixes mingw-libvirt RPM build
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
docs/Makefile.am | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index eb8de80b9c..66f164a1ac 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -214,9 +214,7 @@ manpages7_rst = \
$(KEYCODES:%=manpages/virkeycode-%.rst) \
$(KEYNAMES:%=manpages/virkeyname-%.rst) \
$(NULL)
-manpages8_rst = \
- manpages/virt-sanlock-cleanup.rst \
- $(NULL)
+manpages8_rst = $(NULL)
manpages_rst += \
$(manpages1_rst) \
$(manpages7_rst) \
@@ -245,6 +243,11 @@ if WITH_LOGIN_SHELL
else ! WITH_LOGIN_SHELL
manpages_rst += manpages/virt-login-shell.rst
endif ! WITH_LOGIN_SHELL
+if WITH_SANLOCK
+ manpages8_rst += manpages/virt-sanlock-cleanup.rst
+else ! WITH_SANLOCK
+ manpages_rst += manpages/virt-sanlock-cleanup.rst
+endif ! WITH_SANLOCK
manpages_rst_html_in = \
$(manpages_rst:%.rst=%.html.in)
manpages_html = \
--
2.23.0
4 years, 11 months
[libvirt] [PATCH] util: Simplify Windows version of virGetUserDirectoryByUID()
by Fabiano Fidêncio
Let's just use the plain g_get_home_dir(), from GLib, instead of
maintaining a code adapted from the GLib's one.
Signed-off-by: Fabiano Fidêncio <fidencio(a)redhat.com>
---
src/util/virutil.c | 92 +---------------------------------------------
1 file changed, 1 insertion(+), 91 deletions(-)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index a28feb3daa..4075047cf9 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1070,100 +1070,10 @@ virDoesGroupExist(const char *name G_GNUC_UNUSED)
}
# ifdef WIN32
-/* These methods are adapted from GLib2 under terms of LGPLv2+ */
-static int
-virGetWin32SpecialFolder(int csidl, char **path)
-{
- char buf[MAX_PATH+1];
- LPITEMIDLIST pidl = NULL;
- int ret = 0;
-
- *path = NULL;
-
- if (SHGetSpecialFolderLocation(NULL, csidl, &pidl) == S_OK) {
- if (SHGetPathFromIDList(pidl, buf))
- *path = g_strdup(buf);
- CoTaskMemFree(pidl);
- }
- return ret;
-}
-
-static int
-virGetWin32DirectoryRoot(char **path)
-{
- char windowsdir[MAX_PATH];
-
- *path = NULL;
-
- if (GetWindowsDirectory(windowsdir, G_N_ELEMENTS(windowsdir))) {
- const char *tmp;
- /* Usually X:\Windows, but in terminal server environments
- * might be an UNC path, AFAIK.
- */
- tmp = virFileSkipRoot(windowsdir);
- if (VIR_FILE_IS_DIR_SEPARATOR(tmp[-1]) &&
- tmp[-2] != ':')
- tmp--;
-
- windowsdir[tmp - windowsdir] = '\0';
- } else {
- strcpy(windowsdir, "C:\\");
- }
-
- *path = g_strdup(windowsdir);
- return 0;
-}
-
-
-
char *
virGetUserDirectoryByUID(uid_t uid G_GNUC_UNUSED)
{
- /* Since Windows lacks setuid binaries, and since we already fake
- * geteuid(), we can safely assume that this is only called when
- * querying about the current user */
- const char *dir;
- char *ret;
-
- dir = getenv("HOME");
-
- /* Only believe HOME if it is an absolute path and exists */
- if (dir) {
- if (!virFileIsAbsPath(dir) ||
- !virFileExists(dir))
- dir = NULL;
- }
-
- /* In case HOME is Unix-style (it happens), convert it to
- * Windows style.
- */
- if (dir) {
- char *p;
- while ((p = strchr(dir, '/')) != NULL)
- *p = '\\';
- }
-
- if (!dir)
- /* USERPROFILE is probably the closest equivalent to $HOME? */
- dir = getenv("USERPROFILE");
-
- ret = g_strdup(dir);
-
- if (!ret &&
- virGetWin32SpecialFolder(CSIDL_PROFILE, &ret) < 0)
- return NULL;
-
- if (!ret &&
- virGetWin32DirectoryRoot(&ret) < 0)
- return NULL;
-
- if (!ret) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to determine home directory"));
- return NULL;
- }
-
- return ret;
+ return g_strdup(g_get_home_dir());
}
char *
--
2.23.0
4 years, 11 months
[libvirt] [PATCH v6 0/4] PCI hostdev partial assignment support
by Daniel Henrique Barboza
changes from previous version 5 [1]:
- changes in the commit message of patch 1 and the
documentation included in patches 3 and 4, all of them
suggested/hinted by Alex Williamson.
Daniel Henrique Barboza (4):
Introducing new address type='unassigned' for PCI hostdevs
qemu: handle unassigned PCI hostdevs in command line
formatdomain.html.in: document <address type='unassigned'/>
news.xml: add address type='unassigned' entry
[1] https://www.redhat.com/archives/libvir-list/2019-December/msg01097.html
docs/formatdomain.html.in | 10 ++++
docs/news.xml | 14 +++++
docs/schemas/domaincommon.rng | 5 ++
src/conf/device_conf.c | 2 +
src/conf/device_conf.h | 1 +
src/conf/domain_conf.c | 7 ++-
src/qemu/qemu_command.c | 5 ++
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain_address.c | 5 ++
.../hostdev-pci-address-unassigned.args | 31 ++++++++++
.../hostdev-pci-address-unassigned.xml | 42 ++++++++++++++
tests/qemuxml2argvtest.c | 4 ++
.../hostdev-pci-address-unassigned.xml | 58 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
14 files changed, 185 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-unassigned.args
create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-unassigned.xml
create mode 100644 tests/qemuxml2xmloutdata/hostdev-pci-address-unassigned.xml
--
2.23.0
4 years, 11 months
[libvirt] [PATCH v2 0/4] move qemucaps validations from qemu_command to qemu_domain
by Daniel Henrique Barboza
Most of the patches were pushed in the first version. These
are the patches that didn't make the cut and needed new
versions.
After these patches I'll refrain from doing more validation
moves to qemu_domain.c. I'll send a RFC discussing how we can
move all the validations to a new file first, then we can
resume this work in the definitive location instead.
Changes from previous version 1 [1]:
- patch 1 (former patch 04): moved the validation to a new
qemuDomainDeviceDefValidateMemory() function which is called by
qemuDomainDeviceDefValidate().
- patch 2 (former patch 23): added the missing
"if (graphics->data.egl_headless.rendernode)" check.
- patch 3 (former patch 24): virReportEnumRangeError is now being
used in the "default" label error case.
- patch 4 (new): added the VMCOREINFO validation case that I
mentioned about in the cover letter of [1] as a difficult
case, but Cole mentioned that it was simpler than that and that I
was probably missing something. Cole was right.
[1] https://www.redhat.com/archives/libvir-list/2019-December/msg00570.html
Daniel Henrique Barboza (4):
qemu: command: move NVDIMM validation to qemu_domain.c
qemu: command: move qemuBuildGraphicsEGLHeadlessCommandLine validation
to qemu_domain.c
qemu: move qemuBuildSmartcardCommandLine validation to qemu_domain.c
qemu: command: move validation of vmcoreinfo to qemu_domain.c
src/qemu/qemu_command.c | 51 ++----------------------------
src/qemu/qemu_domain.c | 70 +++++++++++++++++++++++++++++++++++++++--
tests/qemuxml2xmltest.c | 30 +++++++++---------
3 files changed, 87 insertions(+), 64 deletions(-)
--
2.23.0
4 years, 11 months