[libvirt] [PATCH] qemu: Update balloon state after migration finishes
by Peter Krempa
Since qemu doesn't know at the beginning of migration what the actual
balloon size is until the migration stream transfers the appropriate
fields we also need to update the balloon size unconditionally in the
finish phase of the migration.
---
src/qemu/qemu_migration.c | 4 ++++
src/qemu/qemu_process.c | 2 +-
src/qemu/qemu_process.h | 4 ++++
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 903612b..38649ed 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -5701,6 +5701,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
if (qemuMigrationStopNBDServer(driver, vm, mig) < 0)
goto endjob;
+ if (qemuProcessRefreshBalloonState(driver, vm,
+ QEMU_ASYNC_JOB_MIGRATION_IN) < 0)
+ goto endjob;
+
if (flags & VIR_MIGRATE_PERSIST_DEST) {
if (qemuMigrationPersist(driver, vm, mig, !v3proto) < 0) {
/* Hmpf. Migration was successful, but making it persistent
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 7187dc1..f14582b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2091,7 +2091,7 @@ qemuProcessReconnectRefreshChannelVirtioState(virQEMUDriverPtr driver,
}
-static int
+int
qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int asyncJob)
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index d40f68d..b198c2b 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -115,4 +115,8 @@ virDomainDiskDefPtr qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
int qemuConnectAgent(virQEMUDriverPtr driver, virDomainObjPtr vm);
+int qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ int asyncJob);
+
#endif /* __QEMU_PROCESS_H__ */
--
2.4.5
9 years, 2 months
[libvirt] [PATCH 0/4] Remove open coding virProcessWait for root-squash
by John Ferlan
A followup of sorts to recently pushed patches regarding NFS root-squash.
During libvirt-security list review it was pointed out that the new code
was essentially open coding what virProcessWait does. However, since the
model being used also was open coded and there was a time element, the
change was allowed as is with the expectation that a cleanup patch would
follow. Which is what leads into this series....
The series started out purely as removing the open code and replacing
with the call to virProcessWait, but during that exercise I also realized
that it was possible to create a 'netdir' in a NFS root-squash environment
(eg, virDirCreate); however, the corrollary to remove the directory using
a fork/exec didn't exist - in fact all that was called was rmdir, which
failed to delete in the NFS root-squash environment. Rather than having
a whole new interface, the first patch reworks virFileUnlink to check
whether the target is a directory or a file and either call rmdir or
unlink appropriately.
The one common thread amongst the 3 API's changed here is they each looked
to return an errno value, while typically virProcessWait consumers only
return -1 and errno. Determining which failure in virProcessWait returns
-1 is possible because one exit path uses virReportSystemError to report
the error that caused the waitpid() to fail, while the other error path
either receives the errno from the child process or if not present had
already "assumed" EACCES, so these changes follow that model, except that
if it's determined the waitpid failed, EINTR is returned similar to how
virFileAccessibleAs sets errno and returns -1.
John Ferlan (4):
storage: Use virFileUnlink instead of rmdir
virfile: Use virProcessWait in virFileOpenForked
virfile: Use virProcessWait in virFileUnlink
virfile: Use virProcessWait in virDirCreate
src/storage/storage_backend_fs.c | 20 +++--
src/util/virfile.c | 153 ++++++++++++++++-----------------------
2 files changed, 71 insertions(+), 102 deletions(-)
--
2.1.0
9 years, 2 months
[libvirt] [PATCH] vz: remove error logging from prlsdkUUIDParse
by Maxim Nestratov
From: Maxim Nestratov <mnestratov(a)virtuozzo.com>
As far as not every call of prlsdkUUIDParse assume correct UUID
supplied, there is no use to complain about wrong format in it.
Otherwise our log is flooded with false error messages.
For instance, calling prlsdkUUIDParse from prlsdkEventsHandler
works as a filter and in case of uuid absence for event issuer,
we simply know that we shouldn't continue further processing.
Instead of error logging for all calls we should explicitly take
into accaunt where it is called from.
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
src/vz/vz_sdk.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 744b58a..32ca1ef 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -329,8 +329,6 @@ prlsdkUUIDParse(const char *uuidstr, unsigned char *uuid)
/* trim curly braces */
if (virUUIDParse(tmp + 1, uuid) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("UUID in config file malformed"));
ret = -1;
goto error;
}
@@ -365,8 +363,11 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
PrlVmCfg_GetUuid(sdkdom, uuidstr, &len);
prlsdkCheckRetGoto(pret, error);
- if (prlsdkUUIDParse(uuidstr, uuid) < 0)
+ if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Domain UUID is malformed or empty"));
goto error;
+ }
return 0;
@@ -1724,8 +1725,10 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR opaque)
pret = PrlEvent_GetType(prlEvent, &prlEventType);
prlsdkCheckRetGoto(pret, cleanup);
- if (prlsdkUUIDParse(uuidstr, uuid) < 0)
+ if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
+ VIR_DEBUG("Skipping event type %d", prlEventType);
goto cleanup;
+ }
switch (prlEventType) {
case PET_DSP_EVT_VM_STATE_CHANGED:
--
1.7.1
9 years, 2 months
[libvirt] [PATCH] vz: set mount point for container image-based disks
by Maxim Nestratov
From: Maxim Nestratov <mnestratov(a)virtuozzo.com>
In order to support not only root disks with type=file for containers,
we need to specify mount points for them.
For instance, if a secondary disk is added by the following record in
xml:
<disk type='file' device='disk'>
<driver type='ploop' cache='writeback'/>
<source file='/vz/some_path_to_image_dir'/>
<target bus='sata' dev='sdb'/>
</disk>
we are going to add it to container mounted to '/mnt/sdb' path.
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
src/vz/vz_sdk.c | 35 +++++++++++++++++++++++++++++++----
1 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 744b58a..6642933 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3292,21 +3292,48 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom,
goto cleanup;
}
- if (bootDisk == true) {
+ if (bootDisk) {
pret = PrlVmDev_GetIndex(sdkdisk, &devIndex);
prlsdkCheckRetGoto(pret, cleanup);
if (prlsdkAddDeviceToBootList(sdkdom, devIndex, devType, 0) < 0)
goto cleanup;
- /* If we add physical device as a boot disk to container
- * we have to specify mount point for it */
- if (isCt) {
+ }
+
+ if (isCt) {
+
+ /* If we add a disk as a boot disk to a container
+ * (it doesn't matter whether it has image or real device backend)
+ * we have to specify the root mount point for it */
+ if (bootDisk) {
pret = PrlVmDevHd_SetMountPoint(sdkdisk, "/");
prlsdkCheckRetGoto(pret, cleanup);
+ } else {
+
+ /* In case of image we need to specify a mount point
+ * to make it usable within a container */
+ if (disk->src->type == VIR_STORAGE_TYPE_FILE) {
+ char *mount_point;
+ char *dev_name = strrchr(disk->dst, '/');
+
+ if (!dev_name) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Unexpected format of disk destination '%s'."));
+ goto cleanup;
+ }
+
+ if (virAsprintf(&mount_point, "/mnt%s", dev_name) < 0)
+ goto cleanup;
+
+ pret = PrlVmDevHd_SetMountPoint(sdkdisk, mount_point);
+ VIR_FREE(mount_point);
+ prlsdkCheckRetGoto(pret, cleanup);
+ }
}
}
+
return 0;
cleanup:
PrlHandle_Free(sdkdisk);
--
1.7.1
9 years, 2 months
[libvirt] [PATCH] Add a new test case for setUserPassword
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
cases/linux_domain.conf | 22 ++++++++
repos/domain/set_user_passwd.py | 111 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 133 insertions(+)
create mode 100644 repos/domain/set_user_passwd.py
diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 19daded..9a65cf3 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -299,6 +299,28 @@ domain:info_iothread
conn
qemu:///system
+domain:set_user_passwd
+ guestname
+ $defaultname
+ username
+ $username
+ userpassword
+ $password
+ conn
+ qemu:///system
+
+domain:set_user_passwd
+ guestname
+ $defaultname
+ username
+ $username
+ userpassword
+ $password
+ conn
+ qemu:///system
+ flags
+ encrypted
+
domain:destroy
guestname
$defaultname
diff --git a/repos/domain/set_user_passwd.py b/repos/domain/set_user_passwd.py
new file mode 100644
index 0000000..bf9bd06
--- /dev/null
+++ b/repos/domain/set_user_passwd.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+
+import libvirt
+from libvirt import libvirtError
+import lxml
+import lxml.etree
+import crypt
+from utils import utils
+
+required_params = ('guestname', 'username', 'userpassword',)
+optional_params = {'conn': 'qemu:///system', 'flags': '',}
+
+def get_guest_mac(vm):
+ tree = lxml.etree.fromstring(vm.XMLDesc(0))
+ set = tree.xpath("/domain/devices/interface/mac")
+
+ for n in set:
+ return n.attrib['address']
+
+ return False
+
+
+def check_agent_status(vm):
+ """ make sure agent is okay to use """
+
+ tree = lxml.etree.fromstring(vm.XMLDesc(0))
+
+ set = tree.xpath("//channel[@type='unix']/target[@name='org.qemu.guest_agent.0']")
+ for n in set:
+ if n.attrib['state'] == 'connected':
+ return True
+
+ return False
+
+def create_new_user(ipaddr, newusername, username, userpasswd, logger):
+ cmd = "useradd %s" % newusername
+ ret, retinfo = utils.remote_exec_pexpect(ipaddr, username, userpasswd, cmd)
+ if ret == 0 or "already exists" in retinfo:
+ return 0
+ else:
+ logger.error("Fail: cannot create a new user: %s" % retinfo)
+ return 1
+
+def verify_cur_user(ipaddr, username, userpasswd):
+ cmd = "whoami"
+ ret, retinfo = utils.remote_exec_pexpect(ipaddr, username, userpasswd, cmd)
+
+ return ret
+
+def set_user_passwd(params):
+ """
+ test API for setUserPassword in class virDomain
+ """
+
+ logger = params['logger']
+ guest = params['guestname']
+ username = params['username']
+ userpasswd = params['userpassword']
+
+ if 'flags' in params:
+ if params['flags'] == 'encrypted':
+ flags = libvirt.VIR_DOMAIN_PASSWORD_ENCRYPTED
+ else:
+ flags = 0
+ else:
+ flags = 0
+
+ try:
+ if 'conn' in params:
+ conn = libvirt.open(params['conn'])
+ else:
+ conn = libvirt.open(optional_params['conn'])
+
+ logger.info("get connection to libvirtd")
+ vm = conn.lookupByName(guest)
+ logger.info("test guest name: %s" % guest)
+
+ if not check_agent_status(vm):
+ logger.error("guest agent is not connected")
+ return 1
+
+ mac = get_guest_mac(vm)
+ if not mac:
+ logger.error("cannot get guest interface mac")
+ return 1
+
+ ipaddr = utils.mac_to_ip(mac, 180)
+ if not ipaddr:
+ logger.error("cannot get guest IP")
+ return 1
+
+ if flags > 0:
+ passwd = crypt.crypt("123456", crypt.mksalt(crypt.METHOD_SHA512))
+ else:
+ passwd = "123456"
+
+
+ if create_new_user(ipaddr, "usertestapi", username, userpasswd, logger) != 0:
+ return 1
+
+ vm.setUserPassword("usertestapi", passwd, flags)
+
+ if verify_cur_user(ipaddr, "usertestapi", "123456") != 0:
+ logger.error("cannot login guest via new user")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s" % e.message)
+ return 1
+
+ return 0
--
1.8.3.1
9 years, 2 months
[libvirt] [PATCH v2 0/7] Allow startupPolicy change on update-device
by Michal Privoznik
So, as Peter pointed out, we may want to updated startupPolicy for
live domains too. That's what patches 2/7-7/7 do.
Michal Privoznik (7):
qemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again
qemu: s/qemuDomainChangeDiskMediaLive/qemuDomainChangeDiskLive/
qemu_domain: Introduce qemuDomainDiskSourceDiffers
qemuDomainChangeDiskLive: rework slightly
qemu: s/virDomainDiskDiffersSourceOnly/qemuDomainDiskChangeSupported/
qemuDomainDiskChangeSupported: Fill in missing checks
qemuDomainChangeDiskLive: Allow startupPolicy change
src/conf/domain_conf.c | 127 ----------------------------------
src/conf/domain_conf.h | 2 -
src/libvirt_private.syms | 1 -
src/qemu/qemu_domain.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 7 ++
src/qemu/qemu_driver.c | 80 ++++++++++++---------
6 files changed, 232 insertions(+), 161 deletions(-)
--
2.4.6
9 years, 2 months
[libvirt] [libvirt-php] error compiling on OS X 10.11 GM
by Andy Blyler
I’m attempting to compile the HEAD of the git repo on OS X 10.11 GM and I’m getting the following error:
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in src
/bin/sh ../libtool --tag=CC --mode=link clang -I/usr/local/Cellar/php56/5.6.13_2/include/php -I/usr/local/Cellar/php56/5.6.13_2/include/php/main -I/usr/local/Cellar/php56/5.6.13_2/include/php/TSRM -I/usr/local/Cellar/php56/5.6.13_2/include/php/Zend -I/usr/local/Cellar/php56/5.6.13_2/include/php/ext -I/usr/local/Cellar/php56/5.6.13_2/include/php/ext/date/lib -I/usr/local/Cellar/libxml2/2.9.2/include/libxml2 -I/usr/local/Cellar/libvirt/1.2.19/include -I/usr/local/Cellar/libvirt/1.2.19/include -DHAVE_CONFIG_H -I../winsrc -DCOMPILE_DL_LIBVIRT=1 -g -O2 -L/usr/local/Cellar/libxml2/2.9.2/lib -lxml2 -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt-qemu -lvirt -o libvirt-php.la -rpath /usr/local/Cellar/php56-libvirt/HEAD/lib libvirt_php_la-vncfunc.lo libvirt_php_la-sockets.lo libvirt_php_la-libvirt-php.lo
libtool: link: clang -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libvirt-php.0.dylib .libs/libvirt_php_la-vncfunc.o .libs/libvirt_php_la-sockets.o .libs/libvirt_php_la-libvirt-php.o -L/usr/local/Cellar/libxml2/2.9.2/lib -lxml2 -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt-qemu -lvirt -g -O2 -install_name /usr/local/Cellar/php56-libvirt/HEAD/lib/libvirt-php.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-single_module
duplicate symbol _gdebug in:
.libs/libvirt_php_la-vncfunc.o
.libs/libvirt_php_la-sockets.o
duplicate symbol _gdebug in:
.libs/libvirt_php_la-vncfunc.o
.libs/libvirt_php_la-libvirt-php.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My environment is:
OS X: 10.11-x86_64
Xcode: 7.0
CLT: 7.0.0.0.1.1441394355
Clang: 7.0 build 700
X11: N/A
9 years, 2 months
[libvirt] [libvirt-php] error compiling on OS X 10.11 GM
by Andy Blyler
I’m attempting to compile the HEAD of the git repo on OS X 10.11 GM and I’m getting the following error:
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in src
/bin/sh ../libtool --tag=CC --mode=link clang -I/usr/local/Cellar/php56/5.6.13_2/include/php -I/usr/local/Cellar/php56/5.6.13_2/include/php/main -I/usr/local/Cellar/php56/5.6.13_2/include/php/TSRM -I/usr/local/Cellar/php56/5.6.13_2/include/php/Zend -I/usr/local/Cellar/php56/5.6.13_2/include/php/ext -I/usr/local/Cellar/php56/5.6.13_2/include/php/ext/date/lib -I/usr/local/Cellar/libxml2/2.9.2/include/libxml2 -I/usr/local/Cellar/libvirt/1.2.19/include -I/usr/local/Cellar/libvirt/1.2.19/include -DHAVE_CONFIG_H -I../winsrc -DCOMPILE_DL_LIBVIRT=1 -g -O2 -L/usr/local/Cellar/libxml2/2.9.2/lib -lxml2 -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt-qemu -lvirt -o libvirt-php.la -rpath /usr/local/Cellar/php56-libvirt/HEAD/lib libvirt_php_la-vncfunc.lo libvirt_php_la-sockets.lo libvirt_php_la-libvirt-php.lo
libtool: link: clang -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libvirt-php.0.dylib .libs/libvirt_php_la-vncfunc.o .libs/libvirt_php_la-sockets.o .libs/libvirt_php_la-libvirt-php.o -L/usr/local/Cellar/libxml2/2.9.2/lib -lxml2 -L/usr/local/Cellar/libvirt/1.2.19/lib -lvirt-qemu -lvirt -g -O2 -install_name /usr/local/Cellar/php56-libvirt/HEAD/lib/libvirt-php.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-single_module
duplicate symbol _gdebug in:
.libs/libvirt_php_la-vncfunc.o
.libs/libvirt_php_la-sockets.o
duplicate symbol _gdebug in:
.libs/libvirt_php_la-vncfunc.o
.libs/libvirt_php_la-libvirt-php.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My environment is:
OS X: 10.11-x86_64
Xcode: 7.0
CLT: 7.0.0.0.1.1441394355
Clang: 7.0 build 700
X11: N/A
9 years, 2 months
[libvirt] [PATCH] libxl: fix AttachDeviceConfig on hostdev type
by Chunyan Liu
After attach-device a <hostdev> with --config, new device doesn't
show up in dumpxml and in guest.
To fix that, set dev->data.hostdev = NULL after work so that the
pointer is not freed, since vmdef has the pointer and still need it.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
src/libxl/libxl_driver.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e2797d5..8087c27 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3312,6 +3312,7 @@ libxlDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev)
if (virDomainHostdevInsert(vmdef, hostdev) < 0)
return -1;
+ dev->data.hostdev = NULL;
break;
default:
--
1.8.5.6
9 years, 2 months
[libvirt] [PATCH v2 0/8] Simplify and fix qemuMigrationFinish
by Jiri Denemark
While hacking qemuMigrationFinish I found it pretty hard to follow and
revealed few bugs (patches 3 to 5, and 8) in the code.
Version 2:
- rebased and review comments addressed
- new patch "qemu: Fix some corner cases in persistent migration"
Jiri Denemark (8):
qemu: Split qemuMigrationFinish
qemu: Simplify qemuMigrationFinish
qemu: Don't fail migration on save status failure
qemu: Kill domain when migration finish fails
qemu: Don't report false errors in migration protocol v2
qemuDomainEventQueue: Check if event is non-NULL
qemu: Queue events in migration Finish phase ASAP
qemu: Fix some corner cases in persistent migration
src/qemu/qemu_blockjob.c | 6 +-
src/qemu/qemu_cgroup.c | 3 +-
src/qemu/qemu_domain.c | 6 +-
src/qemu/qemu_driver.c | 87 +++++++-----------
src/qemu/qemu_hotplug.c | 26 +++---
src/qemu/qemu_migration.c | 223 ++++++++++++++++++++++++----------------------
src/qemu/qemu_process.c | 72 +++++----------
7 files changed, 187 insertions(+), 236 deletions(-)
--
2.5.1
9 years, 2 months