Re: [libvirt] [PATCH 11/17] Add functions for adding USB controllers to addrs

2016-06-20 Thread Gerd Hoffmann
  Hi,

> +case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI:
> +return 4;

That one is configurable via "ports=...":



cheers,
  Gerd


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 14/17] Assign addresses to USB devices

2016-06-20 Thread Gerd Hoffmann
On Fr, 2016-06-17 at 20:07 +0200, Ján Tomko wrote:
> Automatically assign addresses to USB devices.
> 
> Just like reserving, this is only done for newly defined domains.

What happens if I add a device to a guest (using virsh edit)?

cheers,
  Gerd


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] vz: handle gracefully races on undefining domain

2016-06-20 Thread Nikolay Shirokovskiy
  This patch is not critical but nice to have. The original motivation
was error message in logs on undefining domain thru vz driver.
Undefine procedure drops domain lock while waiting for detaching
disks vz sdk call. Meanwhile vz sdk event domain-config-changed
arrives, its handler finds domain and is blocked waiting for job
condition. After undefine API call finishes event processing procedes
and tries to refreshes domain config thru existing vz sdk domain handle.
Domain does not exists anymore and event processing fails. Everything
is fine we just don't want to see error message in log for this
particular case.

  Fortunately domain has flag that domain is removed from list. This
also imply that vz sdk domain is also undefined. Thus if we check
for this flag right after domain is locked again on accuiring
job condition we gracefully handle this situation.

  Actually the race can happen in other situations too. Any
time we wait for job condition in mutualy exclusive job in
time when we acquire it vz sdk domain can cease to exist.
So instead of general internal error we can return domain
not found which is easier to handle. We don't need to patch
other places in mutually exclusive jobs where domain lock
is dropped as if job is started domain can't be undefine
by mutually exclusive undefine job.

  In case of API calls that are not jobs (load snapshots etc) we'd
better to check if domain exists every time domain lock is
reacquired. Fortunately these calls drop domain lock only
once to call appropriate vz sdk API call.

  The code of this patch is quite similar to qemu driver checks
for is domain is active after acquiring a job. The difference
only while qemu domain is operational while process is active
vz domain is operational while domain exists.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_driver.c | 46 ++
 src/vz/vz_sdk.c| 32 +---
 2 files changed, 75 insertions(+), 3 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 6a508b3..67db2d9 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -716,6 +716,22 @@ vzDomainGetAutostart(virDomainPtr domain, int *autostart)
 return 0;
 }
 
+static bool
+vzDomainObjIsExist(virDomainObjPtr dom)
+{
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+if (!dom->removing)
+return true;
+
+virUUIDFormat(dom->def->uuid, uuidstr);
+virReportError(VIR_ERR_NO_DOMAIN,
+   _("no domain with matching uuid '%s' (%s)"),
+   uuidstr, dom->def->name);
+
+return false;
+}
+
 static virDomainPtr
 vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags)
 {
@@ -782,6 +798,9 @@ vzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, 
unsigned int flags)
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 if (prlsdkApplyConfig(driver, dom, def))
 goto cleanup;
 
@@ -1012,6 +1031,9 @@ vzDomainUndefineFlags(virDomainPtr domain,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 ret = prlsdkUnregisterDomain(privconn->driver, dom, flags);
 
  cleanup:
@@ -1069,6 +1091,9 @@ vzDomainManagedSave(virDomainPtr domain, unsigned int 
flags)
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 state = virDomainObjGetState(dom, &reason);
 
 if (state == VIR_DOMAIN_RUNNING && (flags & VIR_DOMAIN_SAVE_PAUSED)) {
@@ -1159,6 +1184,9 @@ static int vzDomainAttachDeviceFlags(virDomainPtr domain, 
const char *xml,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 switch (dev->type) {
 case VIR_DOMAIN_DEVICE_DISK:
 ret = prlsdkAttachVolume(privconn->driver, dom, dev->data.disk);
@@ -1227,6 +1255,9 @@ static int vzDomainDetachDeviceFlags(virDomainPtr domain, 
const char *xml,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 switch (dev->type) {
 case VIR_DOMAIN_DEVICE_DISK:
 ret = prlsdkDetachVolume(dom, dev->data.disk);
@@ -1284,6 +1315,9 @@ vzDomainSetUserPassword(virDomainPtr domain,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 ret = prlsdkDomainSetUserPassword(dom, user, password);
 
  cleanup:
@@ -1617,6 +1651,9 @@ static int vzDomainSetMemoryFlagsImpl(virDomainPtr 
domain, unsigned long memory,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 ret = prlsdkSetMemsize(dom, memory >> 10);
 
  cleanup:
@@ -2101,6 +2138,9 @@ vzDomainSnapshotCreateXML(virDomainPtr domain,
 goto cleanup;
 job = true;
 
+if (!vzDomainObjIsExist(dom))
+goto cleanup;
+
 /* snaphot name is ignored, it will be set to auto generated by sdk uu

Re: [libvirt] [PATCH] qemu: Don't use legacy USB for aarch64 mach-virt guests

2016-06-20 Thread Andrea Bolognani
On Sat, 2016-06-18 at 10:12 +0200, Andrew Jones wrote:
> > > ACK from me.
> > 
> > Great, thanks! I'll wait for Drew's thumbs up before
> > actually pushing this, though.
> 
> Thumbs up.
> 
> -usb should probably even be removed from QEMU. The help
> text says
> 
>  -usbenable the USB driver (will be the default soon)
> 
> I got tired of trying to hunt down the commit that added
> the 'default soon' stuff since it's so old...

Cool, I just pushed it. Thanks!

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] virsh migrate: Fix positional parameters

2016-06-20 Thread Jiri Denemark
Thanks to our smart option parser which automatically assigns positional
parameters the following (previously working) command fails:

virsh migrate test qemu+ssh://1.2.3.4/system tcp://1.2.3.4/
error: invalid argument: Unsupported compression method
'tcp://1.2.3.4/'

We need to make sure new options are added at the end of the list rather
than where they logically belong.

Reported by Brian Rak.

Signed-off-by: Jiri Denemark 
---
 tools/virsh-domain.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 02be58f..19c40b3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9792,26 +9792,6 @@ static const vshCmdOptDef opts_migrate[] = {
  .type = VSH_OT_BOOL,
  .help = N_("compress repeated pages during live migration")
 },
-{.name = "comp-methods",
- .type = VSH_OT_STRING,
- .help = N_("comma separated list of compression methods to be used")
-},
-{.name = "comp-mt-level",
- .type = VSH_OT_INT,
- .help = N_("compress level for multithread compression")
-},
-{.name = "comp-mt-threads",
- .type = VSH_OT_INT,
- .help = N_("number of compression threads for multithread compression")
-},
-{.name = "comp-mt-dthreads",
- .type = VSH_OT_INT,
- .help = N_("number of decompression threads for multithread compression")
-},
-{.name = "comp-xbzrle-cache",
- .type = VSH_OT_INT,
- .help = N_("page cache size for xbzrle compression")
-},
 {.name = "auto-converge",
  .type = VSH_OT_BOOL,
  .help = N_("force convergence during live migration")
@@ -9873,6 +9853,26 @@ static const vshCmdOptDef opts_migrate[] = {
  .type = VSH_OT_INT,
  .help = N_("port to use by target server for incoming disks migration")
 },
+{.name = "comp-methods",
+ .type = VSH_OT_STRING,
+ .help = N_("comma separated list of compression methods to be used")
+},
+{.name = "comp-mt-level",
+ .type = VSH_OT_INT,
+ .help = N_("compress level for multithread compression")
+},
+{.name = "comp-mt-threads",
+ .type = VSH_OT_INT,
+ .help = N_("number of compression threads for multithread compression")
+},
+{.name = "comp-mt-dthreads",
+ .type = VSH_OT_INT,
+ .help = N_("number of decompression threads for multithread compression")
+},
+{.name = "comp-xbzrle-cache",
+ .type = VSH_OT_INT,
+ .help = N_("page cache size for xbzrle compression")
+},
 {.name = NULL}
 };
 
-- 
2.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 1/7] domain_conf: Validate redirdev after parsing

2016-06-20 Thread Ján Tomko

On Fri, Jun 10, 2016 at 05:32:55PM +0200, Michal Privoznik wrote:

There's currently just one limitation: redirdevs that want to go
on USB bus require a USB controller, surprisingly.
At the same time, since I'm using virDomainDefHasUSB() in this
new validator function, it has to be moved a few lines up and
also its header needed to be changed a bit: it is now taking a
const pointer to domain def since it's not changing anything in
there.

Signed-off-by: Michal Privoznik 
---
src/conf/domain_conf.c | 56 --
1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 85f6e31..c75279d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4567,14 +4567,45 @@ virDomainDiskDefValidate(const virDomainDiskDef *disk)
return 0;
}

+static bool
+virDomainDefHasUSB(const virDomainDef *def)
+{
+size_t i;
+
+for (i = 0; i < def->ncontrollers; i++) {
+if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
+def->controllers[i]->model != VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE)
+return true;
+}


This function returns false either if there is a model='none' USB
controller or if there is none at all,


+
+return false;
+}
+



@@ -17060,14 +17090,6 @@ virDomainDefParseXML(xmlDocPtr xml,
if (!redirdev)
goto error;

-if (redirdev->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && usb_none) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-_("Can't add redirected USB device: "
-  "USB is disabled for this domain"));
-virDomainRedirdevDefFree(redirdev);


but this error was only reported for model="none'.

This broke virt-manager's test:
https://ci.centos.org/job/virt-manager-test/systems=libvirt-fedora-rawhide/1363/console

Jan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2] maint: Switch to xz compressed PAX release archives

2016-06-20 Thread Ján Tomko

On Wed, Jun 15, 2016 at 10:31:16AM -0400, Laine Stump wrote:

On 06/15/2016 09:03 AM, Andrea Bolognani wrote:

This allows us to produce releases that are roughly a third in
size, have no limitation on path length, and are still readable
by all supported platforms.
---


I just want to point out that the tarfile is built every time you run
"make rpm" (which I do quite a lot - I prefer installing rpms to the
carnage created by make install), and this increases the time for make
rpm on my system by 1min38sec. (jtomko may have something to say about
that, since he's been interested in shaving fractions of a second off
the build time in the last few days :-O)



Use:
XZ_OPT="-3 --threads=0" make rpm

The most important speedup comes from dropping the '-e' option
which automake uses by default.

(-1 is faster than -0 in my testing, -2 and -3 take a few seconds more
but drop megabytes off the size. All of them are faster and result in
a smaller size than gz --best we used before)

On my RHEL, rpmbuild does not recompress sources by default,
so this will leave you with a larger srpm.
For binary data, the default level is 2:
%_binary_payload w2.xzdio
but even then the *rpms made with lower compression leves were
marginally larger than the default ones. I did not find out why.

Jan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] vz: handle gracefully races on undefining domain

2016-06-20 Thread Nikolay Shirokovskiy


On 20.06.2016 10:40, Nikolay Shirokovskiy wrote:
>   This patch is not critical but nice to have. The original motivation
> was error message in logs on undefining domain thru vz driver.
> Undefine procedure drops domain lock while waiting for detaching
> disks vz sdk call. Meanwhile vz sdk event domain-config-changed
> arrives, its handler finds domain and is blocked waiting for job
> condition. After undefine API call finishes event processing procedes
> and tries to refreshes domain config thru existing vz sdk domain handle.
> Domain does not exists anymore and event processing fails. Everything
> is fine we just don't want to see error message in log for this
> particular case.
> 
>   Fortunately domain has flag that domain is removed from list. This
> also imply that vz sdk domain is also undefined. Thus if we check
> for this flag right after domain is locked again on accuiring
> job condition we gracefully handle this situation.
> 
>   Actually the race can happen in other situations too. Any
> time we wait for job condition in mutualy exclusive job in
> time when we acquire it vz sdk domain can cease to exist.
> So instead of general internal error we can return domain
> not found which is easier to handle. We don't need to patch
> other places in mutually exclusive jobs where domain lock
> is dropped as if job is started domain can't be undefine
> by mutually exclusive undefine job.
> 
>   In case of API calls that are not jobs (load snapshots etc) we'd
> better to check if domain exists every time domain lock is
> reacquired. Fortunately these calls drop domain lock only
> once to call appropriate vz sdk API call.
> 
>   The code of this patch is quite similar to qemu driver checks
> for is domain is active after acquiring a job. The difference
> only while qemu domain is operational while process is active
> vz domain is operational while domain exists.
> 
> Signed-off-by: Nikolay Shirokovskiy 
> ---
>  src/vz/vz_driver.c | 46 ++
>  src/vz/vz_sdk.c| 32 +---
>  2 files changed, 75 insertions(+), 3 deletions(-)
> 

[snip]

Another case of hindsight is 20/20 )) I think the below changes are 
not good and should be dropped from the patch. We can't rely on 'removing' 
flag in case other then mutually exclusive jobs.

>  
> +static void
> +vzDomainObjCheckExist(virDomainObjPtr dom)
> +{
> +char uuidstr[VIR_UUID_STRING_BUFLEN];
> +
> +if (!dom->removing)
> +return;
> +
> +virUUIDFormat(dom->def->uuid, uuidstr);
> +virReportError(VIR_ERR_NO_DOMAIN,
> +   _("no domain with matching uuid '%s' (%s)"),
> +   uuidstr, dom->def->name);
> +}
> +
>  int
>  prlsdkDomainManagedSaveRemove(virDomainObjPtr dom)
>  {
> @@ -3959,8 +3979,10 @@ prlsdkDomainManagedSaveRemove(virDomainObjPtr dom)
>  PRL_HANDLE job;
>  
>  job = PrlVm_DropSuspendedState(privdom->sdkdom);
> -if (PRL_FAILED(waitDomainJob(job, dom)))
> +if (PRL_FAILED(waitDomainJob(job, dom))) {
> +vzDomainObjCheckExist(dom);
>  return -1;
> +}
>  
>  return 0;
>  }
> @@ -4394,8 +4416,10 @@ prlsdkLoadSnapshots(virDomainObjPtr dom)
>  char *treexml = NULL;
>  
>  job = PrlVm_GetSnapshotsTreeEx(privdom->sdkdom, 
> PGST_WITHOUT_SCREENSHOTS);
> -if (PRL_FAILED(getDomainJobResult(job, dom, &result)))
> +if (PRL_FAILED(getDomainJobResult(job, dom, &result))) {
> +vzDomainObjCheckExist(dom);
>  goto cleanup;
> +}
>  
>  if (!(treexml = prlsdkGetStringParamVar(PrlResult_GetParamAsString, 
> result)))
>  goto cleanup;
> @@ -4427,8 +4451,10 @@ int prlsdkDeleteSnapshot(virDomainObjPtr dom, const 
> char *uuid, bool children)
>  PRL_HANDLE job;
>  
>  job = PrlVm_DeleteSnapshot(privdom->sdkdom, uuid, children);
> -if (PRL_FAILED(waitDomainJob(job, dom)))
> +if (PRL_FAILED(waitDomainJob(job, dom))) {
> +vzDomainObjCheckExist(dom);
>  return -1;
> +}
>  
>  return 0;
>  }
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/7] *** Add VirtualBox 5 support to libvirt ***

2016-06-20 Thread Martin Pietsch
*** BLURB HERE ***

Martin Pietsch (7):
  add VirtualBox 5 C API to libvirt
  add VirtualBox 5 support to vbox_tmpl.c
  add VirtualBox5 support to vbox_uniformed_api.h
  add vbox_V5_0.c for libvirt support of VirtualBox 5
  append vbox_V5_0.c and vbox_CAPI_v5_0.h to src/Makefile.am
  add VirtualBox 5 support to vbox_common.h
  add VirtualBox 5 support to vbox_storage.c

 src/Makefile.am   | 1 +
 src/vbox/vbox_CAPI_v5_0.h | 25550 
 src/vbox/vbox_V5_0.c  |13 +
 src/vbox/vbox_common.h| 2 +
 src/vbox/vbox_storage.c   | 2 +
 src/vbox/vbox_tmpl.c  |84 +-
 src/vbox/vbox_uniformed_api.h | 1 +
 7 files changed, 25647 insertions(+), 6 deletions(-)
 create mode 100644 src/vbox/vbox_CAPI_v5_0.h
 create mode 100644 src/vbox/vbox_V5_0.c

-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/2] vz: add getting job info for migration

2016-06-20 Thread Nikolay Shirokovskiy
Nikolay Shirokovskiy (2):
  vz: add getting job info for migration
  vz: add vzDomainGetJobStats

 src/vz/vz_driver.c | 113 +
 src/vz/vz_sdk.c|  31 +++
 src/vz/vz_utils.c  |  42 
 src/vz/vz_utils.h  |  17 +++-
 4 files changed, 194 insertions(+), 9 deletions(-)

-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] vz: add getting job info for migration

2016-06-20 Thread Nikolay Shirokovskiy
Unfortunately vz sdk do not provide detail information on migration
progress, only progress percentage. Thus vz driver provides percents
instead of bytes in data fields of virDomainJobInfoPtr.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_driver.c | 42 ++
 src/vz/vz_sdk.c| 31 +++
 src/vz/vz_utils.c  | 42 +++---
 src/vz/vz_utils.h  | 17 +++--
 4 files changed, 123 insertions(+), 9 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index b35469a..7be2a5a 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2539,6 +2539,7 @@ vzDomainMigratePerformStep(virDomainPtr domain,
 {
 int ret = -1;
 virDomainObjPtr dom = NULL;
+vzDomObjPtr privdom;
 virURIPtr vzuri = NULL;
 vzConnPtr privconn = domain->conn->privateData;
 const char *miguri = NULL;
@@ -2573,6 +2574,8 @@ vzDomainMigratePerformStep(virDomainPtr domain,
 if (vzDomainObjBeginJob(dom) < 0)
 goto cleanup;
 job = true;
+privdom = dom->privateData;
+privdom->job.hasProgress = true;
 
 if (!vzDomainObjIsExist(dom))
 goto cleanup;
@@ -2794,6 +2797,44 @@ vzDomainMigrateConfirm3Params(virDomainPtr domain 
ATTRIBUTE_UNUSED,
 return 0;
 }
 
+static int
+vzDomainGetJobInfoImpl(virDomainObjPtr dom, virDomainJobInfoPtr info)
+{
+vzDomObjPtr privdom = dom->privateData;
+vzDomainJobObjPtr job = &privdom->job;
+
+memset(info, 0, sizeof(*info));
+
+if (!job->active || !job->hasProgress)
+return 0;
+
+if (vzDomainJobUpdateTime(job) < 0)
+return -1;
+
+info->type = VIR_DOMAIN_JOB_UNBOUNDED;
+info->dataTotal = 100;
+info->dataProcessed = job->progress;
+info->dataRemaining = 100 - job->progress;
+info->timeElapsed = job->elapsed;
+
+return 0;
+}
+
+static int
+vzDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
+{
+virDomainObjPtr dom;
+int ret;
+
+if (!(dom = vzDomObjFromDomain(domain)))
+return -1;
+
+ret = vzDomainGetJobInfoImpl(dom, info);
+
+virObjectUnlock(dom);
+return ret;
+}
+
 static virHypervisorDriver vzHypervisorDriver = {
 .name = "vz",
 .connectOpen = vzConnectOpen,/* 0.10.0 */
@@ -2884,6 +2925,7 @@ static virHypervisorDriver vzHypervisorDriver = {
 .domainMigratePerform3Params = vzDomainMigratePerform3Params, /* 1.3.5 */
 .domainMigrateFinish3Params = vzDomainMigrateFinish3Params, /* 1.3.5 */
 .domainMigrateConfirm3Params = vzDomainMigrateConfirm3Params, /* 1.3.5 */
+.domainGetJobInfo = vzDomainGetJobInfo, /* 2.0.0 */
 };
 
 static virConnectDriver vzConnectDriver = {
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 8abe223..bd67b21 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -1885,6 +1885,34 @@ prlsdkHandlePerfEvent(vzDriverPtr driver,
 virObjectUnlock(dom);
 }
 
+static void
+prlsdkHandleMigrationProgress(vzDriverPtr driver,
+  PRL_HANDLE event,
+  unsigned char *uuid)
+{
+virDomainObjPtr dom = NULL;
+vzDomObjPtr privdom = NULL;
+PRL_UINT32 progress;
+PRL_HANDLE param = PRL_INVALID_HANDLE;
+PRL_RESULT pret;
+
+if (!(dom = virDomainObjListFindByUUID(driver->domains, uuid)))
+return;
+
+pret = PrlEvent_GetParam(event, 0, ¶m);
+prlsdkCheckRetGoto(pret, cleanup);
+
+pret = PrlEvtPrm_ToUint32(param, &progress);
+prlsdkCheckRetGoto(pret, cleanup);
+
+privdom = dom->privateData;
+privdom->job.progress = progress;
+
+ cleanup:
+PrlHandle_Free(param);
+virObjectUnlock(dom);
+}
+
 static PRL_RESULT
 prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR opaque)
 {
@@ -1940,6 +1968,9 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR 
opaque)
 case PET_DSP_EVT_DISP_CONNECTION_CLOSED:
 vzDestroyDriverConnection();
 break;
+case PET_DSP_EVT_VM_MIGRATE_PROGRESS_CHANGED:
+prlsdkHandleMigrationProgress(driver, prlEvent, uuid);
+break;
 default:
 VIR_DEBUG("Skipping event of type %d", prlEventType);
 }
diff --git a/src/vz/vz_utils.c b/src/vz/vz_utils.c
index dc8dbf3..92af4da 100644
--- a/src/vz/vz_utils.c
+++ b/src/vz/vz_utils.c
@@ -459,7 +459,7 @@ vzDomObjAlloc(void)
 if (VIR_ALLOC(pdom) < 0)
 return NULL;
 
-if (virCondInit(&pdom->jobCond) < 0)
+if (virCondInit(&pdom->job.cond) < 0)
 goto error;
 
 pdom->stats = PRL_INVALID_HANDLE;
@@ -482,7 +482,7 @@ vzDomObjFree(void* p)
 
 PrlHandle_Free(pdom->sdkdom);
 PrlHandle_Free(pdom->stats);
-virCondDestroy(&pdom->jobCond);
+virCondDestroy(&pdom->job.cond);
 VIR_FREE(pdom);
 };
 
@@ -499,12 +499,19 @@ vzDomainObjBeginJob(virDomainObjPtr dom)
 return -1;
 then = now + VZ_JOB_WAIT_TIME;
 
-while (pdom->job) {
-if (virCondWaitUntil(&pdom->jobCond, &dom->parent.lock, then) < 0)
+while (pdom->job.active) {
+  

[libvirt] [PATCH 2/2] vz: add vzDomainGetJobStats

2016-06-20 Thread Nikolay Shirokovskiy
Signed-off-by: Nikolay Shirokovskiy 
---
 src/vz/vz_driver.c | 71 ++
 1 file changed, 71 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 7be2a5a..8141a90 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -2835,6 +2835,76 @@ vzDomainGetJobInfo(virDomainPtr domain, 
virDomainJobInfoPtr info)
 return ret;
 }
 
+static int
+vzDomainJobInfoToParams(virDomainJobInfoPtr info,
+int *type,
+virTypedParameterPtr *params,
+int *nparams)
+{
+virTypedParameterPtr par = NULL;
+int maxpar = 0;
+int npar = 0;
+
+if (virTypedParamsAddULLong(&par, &npar, &maxpar,
+VIR_DOMAIN_JOB_TIME_ELAPSED,
+info->timeElapsed) < 0 ||
+virTypedParamsAddULLong(&par, &npar, &maxpar,
+VIR_DOMAIN_JOB_DATA_TOTAL,
+info->dataTotal) < 0 ||
+virTypedParamsAddULLong(&par, &npar, &maxpar,
+VIR_DOMAIN_JOB_DATA_PROCESSED,
+info->dataProcessed) < 0 ||
+virTypedParamsAddULLong(&par, &npar, &maxpar,
+VIR_DOMAIN_JOB_DATA_REMAINING,
+info->dataRemaining) < 0)
+goto error;
+
+
+*type = info->type;
+*params = par;
+*nparams = npar;
+return 0;
+
+ error:
+virTypedParamsFree(par, npar);
+return -1;
+}
+
+static int
+vzDomainGetJobStats(virDomainPtr domain,
+int *type,
+virTypedParameterPtr *params,
+int *nparams,
+unsigned int flags)
+{
+virDomainJobInfo info;
+virDomainObjPtr dom;
+int ret = -1;
+
+virCheckFlags(0, -1);
+
+if (!(dom = vzDomObjFromDomain(domain)))
+return -1;
+
+if (vzDomainGetJobInfoImpl(dom, &info) < 0)
+goto cleanup;
+
+if (info.type == VIR_DOMAIN_JOB_NONE) {
+*type = VIR_DOMAIN_JOB_NONE;
+*params = NULL;
+*nparams = 0;
+ret = 0;
+goto cleanup;
+}
+
+ret = vzDomainJobInfoToParams(&info, type, params, nparams);
+
+ cleanup:
+virObjectUnlock(dom);
+
+return ret;
+}
+
 static virHypervisorDriver vzHypervisorDriver = {
 .name = "vz",
 .connectOpen = vzConnectOpen,/* 0.10.0 */
@@ -2926,6 +2996,7 @@ static virHypervisorDriver vzHypervisorDriver = {
 .domainMigrateFinish3Params = vzDomainMigrateFinish3Params, /* 1.3.5 */
 .domainMigrateConfirm3Params = vzDomainMigrateConfirm3Params, /* 1.3.5 */
 .domainGetJobInfo = vzDomainGetJobInfo, /* 2.0.0 */
+.domainGetJobStats = vzDomainGetJobStats, /* 2.0.0 */
 };
 
 static virConnectDriver vzConnectDriver = {
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/6] Remove virsh-all

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:36 +0200, Ján Tomko wrote:
> Since e8ac4a7 this test wastes some CPU cycles by blindly trying to
> run almost every virsh command, blindly throwing away the output
> and the return value and returning success if 'virsh help' successfully
> returned at least one command.
> 
> Drop it completely.
> ---
>  tests/Makefile.am |  1 -
>  tests/virsh-all   | 52 
>  2 files changed, 53 deletions(-)
>  delete mode 100755 tests/virsh-all

[...]

> diff --git a/tests/virsh-all b/tests/virsh-all
> deleted file mode 100755
> index 4a91e4e..000
> --- a/tests/virsh-all
> +++ /dev/null
> @@ -1,52 +0,0 @@


> -counter=0
> -for i in $cmds; do
> -counter=`eval "expr $counter + 1"`
> -
> -# For now, just run the command and ignore output
> -$abs_top_builddir/tools/virsh -c $test_url $i < /dev/null > /dev/null 
> 2>&1
> -# Temporarily ignoring exit status
> -#status=$?
> -status=0

Lol!

> -test_result $counter $i $status

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh migrate: Fix positional parameters

2016-06-20 Thread Andrea Bolognani
On Mon, 2016-06-20 at 10:31 +0200, Jiri Denemark wrote:
> Thanks to our smart option parser which automatically assigns positional
> parameters the following (previously working) command fails:
> 
> virsh migrate test qemu+ssh://1.2.3.4/system tcp://1.2.3.4/
> error: invalid argument: Unsupported compression method
> 'tcp://1.2.3.4/'
> 
> We need to make sure new options are added at the end of the list rather
> than where they logically belong.
> 
> Reported by Brian Rak.
> 
> Signed-off-by: Jiri Denemark 
> ---
>  tools/virsh-domain.c | 40 
>  1 file changed, 20 insertions(+), 20 deletions(-)

ACK

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] virsh migrate: Fix positional parameters

2016-06-20 Thread Pavel Hrdina
On Mon, Jun 20, 2016 at 10:31:32AM +0200, Jiri Denemark wrote:
> Thanks to our smart option parser which automatically assigns positional
> parameters the following (previously working) command fails:
> 
> virsh migrate test qemu+ssh://1.2.3.4/system tcp://1.2.3.4/
> error: invalid argument: Unsupported compression method
> 'tcp://1.2.3.4/'
> 
> We need to make sure new options are added at the end of the list rather
> than where they logically belong.
> 
> Reported by Brian Rak.
> 
> Signed-off-by: Jiri Denemark 
> ---
>  tools/virsh-domain.c | 40 
>  1 file changed, 20 insertions(+), 20 deletions(-)

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh: introduce name-uuid for list command

2016-06-20 Thread Chen Hanxiao

At 2016-06-15 17:36:05, "Chen Hanxiao"  wrote:
>From: Chen Hanxiao 
>
>This patch will show both name and UUID of domain:
>
> IdName   State  UUID
> ---
>  3 f23running
> 918f1dd6-b19f-412b-ba17-d113bad89af8
>
>Signed-off-by: Chen Hanxiao 
>---

ping?

Regards,
- Chen

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] docs: virsh: Added note for the dump command

2016-06-20 Thread jsuchane
From: Jaroslav Suchanek 

Crash dump in a old kvmdump format is being obsolete and cannot be loaded and
processed by crash utility since its version 6.1.0. A --memory-only option is
required in order to produce valid ELF file which can be later processed by the
crash utility. A new note is added to the dump command description.
---
 tools/virsh.pod | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 98fed76..8e3ba69 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1355,6 +1355,11 @@ B command. I<--verbose> displays the progress of 
dump.
 NOTE: Some hypervisors may require the user to manually ensure proper
 permissions on file and path specified by argument I.

+NOTE: Crash dump in a old kvmdump format is being obsolete and cannot be loaded
+and processed by crash utility since its version 6.1.0. A --memory-only option
+is required in order to produce valid ELF file which can be later processed by
+the crash utility.
+
 =item B I [I<--inactive>] [I<--security-info>]
 [I<--update-cpu>] [I<--migratable>]

-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] gnulib and 32-bit libvirt build, rpl_canonicalize_file_name

2016-06-20 Thread Ian Jackson
The Xen Project's automated test (CI) system has reported a build
failure in libvirt; libvirt uses gnulib.  osstest has bisected it to a
specific gnulib commit.  (Email from osstest is quoted below.)

The error message is:

  ../gnulib/lib/.libs/libgnu.a(canonicalize-lgpl.o): In function
  `rpl_canonicalize_file_name':

  
/home/osstest/build.95966.build-i386-libvirt/libvirt/gnulib/lib/canonicalize-lgpl.c:400:
 multiple definition of `rpl_canonicalize_file_name'

  
.libs/virpcimock_la-virpcimock.o:/home/osstest/build.95966.build-i386-libvirt/libvirt/tests/virpcimock.c:954:
 first defined here

  collect2: error: ld returned 1 exit status

Do you already know about this ?  Would you like us to submit a
patch to gnulib ?

Thanks,
Ian.
 

osstest service owner writes ("[qemu-upstream-4.3-testing bisection] complete 
build-i386-libvirt"):
> branch xen-4.3-testing
> xenbranch xen-4.3-testing
> job build-i386-libvirt
> testid libvirt-build
> 
> Tree: libvirt git://xenbits.xen.org/libvirt.git
> Tree: libvirt_gnulib git://git.sv.gnu.org/gnulib.git
> Tree: qemu git://xenbits.xen.org/qemu-xen-traditional.git
> Tree: qemuu git://xenbits.xen.org/qemu-xen.git
> Tree: xen git://xenbits.xen.org/xen.git
> 
> *** Found and reproduced problem changeset ***
> 
>   Bug is in tree:  libvirt_gnulib git://git.sv.gnu.org/gnulib.git
>   Bug introduced:  54615b95ff238e235e806855efc46a9abad09f2e
>   Bug not present: e78f894d0bdc770101bc040613f4ea94e45f38f7
>   Last fail repro: http://logs.test-lab.xenproject.org/osstest/logs/95966/
> 
> 
>   commit 54615b95ff238e235e806855efc46a9abad09f2e
>   Author: Paul Eggert 
>   Date:   Sat Feb 6 18:11:48 2016 -0800
>   
>   misc: port better to gcc -fsanitize=address
>   
>   Without these patches, ./configure CFLAGS='-fsanitize=address'
>   would compute incorrect values.  This patch fixes some (but not all)
>   test failures with recent glibc, with this configuration.
>   * m4/acl.m4 (gl_ACL_GET_FILE):
>   * m4/calloc.m4 (_AC_FUNC_CALLOC_IF):
>   * m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS):
>   * m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO):
>   * m4/duplocale.m4 (gl_FUNC_DUPLOCALE):
>   * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL):
>   * m4/getdelim.m4 (gl_FUNC_GETDELIM):
>   * m4/getgroups.m4 (gl_FUNC_GETGROUPS):
>   * m4/getline.m4 (gl_FUNC_GETLINE):
>   * m4/malloc.m4 (_AC_FUNC_MALLOC_IF):
>   * m4/realloc.m4 (_AC_FUNC_REALLOC_IF):
>   * m4/regex.m4 (gl_REGEX):
>   * m4/strndup.m4 (gl_FUNC_STRNDUP):
>   * tests/test-calloc-gnu.c (main):
>   * tests/test-duplocale.c (main):
>   * tests/test-getgroups.c (main):
>   * tests/test-getline.c (main):
>   * tests/test-inttostr.c (main):
>   * tests/test-localename.c (test_locale_name)
>   (test_locale_name_thread, test_locale_name_environ)
>   (test_locale_name_default):
>   * tests/test-regex.c (main):
>   * tests/test-setlocale1.c (main):
>   * tests/test-stat.h (test_stat_func):
>   Free heap-allocated storage before exiting.
>   * m4/asm-underscore.m4 (gl_ASM_SYMBOL_PREFIX):
>   Don't match *_foo symbols inserted by AddressSanitizer.
>   * tests/test-regex.c, tests/test-stat.c: Include stdlib.h, for 'free'.
> 
> 
> For bisection revision-tuple graph see:
>
> http://logs.test-lab.xenproject.org/osstest/results/bisect/qemu-upstream-4.3-testing/build-i386-libvirt.libvirt-build.html
> Revision IDs in each graph node refer, respectively, to the Trees above.
> 
> 
> Running cs-bisection-step 
> --graph-out=/home/logs/results/bisect/qemu-upstream-4.3-testing/build-i386-libvirt.libvirt-build
>  --summary-out=tmp/95966.bisection-summary --basis-template=80927 
> --blessings=real,real-bisect qemu-upstream-4.3-testing build-i386-libvirt 
> libvirt-build
> Searching for failure / basis pass:
>  95930 fail [host=fiano0] / 80927 [host=pinot1] 80730 [host=baroque0] 77983 
> [host=pinot0] 77930 [host=italia0] 77853 [host=italia1] 62112 [host=nocera1] 
> 62045 [host=nocera1] 61805 [host=nocera1] 61729 [host=nocera0] 61620 
> [host=pinot1] 60903 [host=nocera1] 60700 [host=nocera0] 60676 [host=nocera0] 
> 60159 [host=italia1] 58381 [host=pinot1] 57828 [host=nocera0] 56721 
> [host=nocera1] 56679 [host=nocera0] 56637 [host=nocera1] 56604 [host=nocera1] 
> 56583 [host=italia1] 56556 [host=nocera0] 56506 [host=nocera1] 56427 
> [host=nocera1] 56373 [host=nocera0] 55875 [host=nocera1] 50282 [host=fiano1] 
> 36518 [host=scape-moth] 31652 [host=lace-bug] template as basis? using 
> template as basis.
> Failure / basis pass flights: 95930 / 80927
> (tree with no url: seabios)
> Tree: libvirt git://xenbits.xen.org/libvirt.git
> Tree: libvirt_gnulib git://git.sv.gnu.org/gnulib.git
> Tree: qemu git://xenbits.xen.org/qemu-xen-traditional.git
> Tree: qemuu git://xenbits.xen.org/qemu-xen.git
> Tree: xen git://xenbits.xen.org/xen.git
> Latest eac167e2610d3e59b32f7ec7ba78cbc8c420a425 
> 246b3b28808ee5f46

Re: [libvirt] gnulib and 32-bit libvirt build, rpl_canonicalize_file_name

2016-06-20 Thread Ján Tomko

On Mon, Jun 20, 2016 at 12:37:23PM +0100, Ian Jackson wrote:

The Xen Project's automated test (CI) system has reported a build
failure in libvirt; libvirt uses gnulib.  osstest has bisected it to a
specific gnulib commit.  (Email from osstest is quoted below.)

The error message is:

 ../gnulib/lib/.libs/libgnu.a(canonicalize-lgpl.o): In function
 `rpl_canonicalize_file_name':

 
/home/osstest/build.95966.build-i386-libvirt/libvirt/gnulib/lib/canonicalize-lgpl.c:400:
 multiple definition of `rpl_canonicalize_file_name'

 
.libs/virpcimock_la-virpcimock.o:/home/osstest/build.95966.build-i386-libvirt/libvirt/tests/virpcimock.c:954:
 first defined here

 collect2: error: ld returned 1 exit status

Do you already know about this ?  Would you like us to submit a
patch to gnulib ?

Thanks,
Ian.


osstest service owner writes ("[qemu-upstream-4.3-testing bisection] complete 
build-i386-libvirt"):

branch xen-4.3-testing
xenbranch xen-4.3-testing
job build-i386-libvirt
testid libvirt-build

Tree: libvirt git://xenbits.xen.org/libvirt.git
Tree: libvirt_gnulib git://git.sv.gnu.org/gnulib.git
Tree: qemu git://xenbits.xen.org/qemu-xen-traditional.git
Tree: qemuu git://xenbits.xen.org/qemu-xen.git
Tree: xen git://xenbits.xen.org/xen.git

*** Found and reproduced problem changeset ***

  Bug is in tree:  libvirt_gnulib git://git.sv.gnu.org/gnulib.git
  Bug introduced:  54615b95ff238e235e806855efc46a9abad09f2e
  Bug not present: e78f894d0bdc770101bc040613f4ea94e45f38f7
  Last fail repro: http://logs.test-lab.xenproject.org/osstest/logs/95966/


  commit 54615b95ff238e235e806855efc46a9abad09f2e
  Author: Paul Eggert 
  Date:   Sat Feb 6 18:11:48 2016 -0800

  misc: port better to gcc -fsanitize=address

  Without these patches, ./configure CFLAGS='-fsanitize=address'
  would compute incorrect values.  This patch fixes some (but not all)
  test failures with recent glibc, with this configuration.


This has been fixed in gnulib already:
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=246b3b2
commit 246b3b28808ee5f4664be674dce573af9497fc7a
Author: Eric Blake 
CommitDate: 2016-05-27 14:04:35 -0600

   canonicalize: Fix broken probe for realpath.

Pulled into libvirt by:
commit 0ebd0b19d35b93eeea9d49318d7a69e147da
Author: Eric Blake 
CommitDate: 2016-05-27 14:06:45 -0600

   maint: update to latest gnulib
   
   Fix a regression in checking for realpath (which caused link

   failures regarding duplicate rpl_canonicalize_file_name), and
   fix the mingw build regarding unsetenv.
   
   * .gnulib: Update to latest.
   
   Signed-off-by: Eric Blake 


git describe: v1.3.5-rc1 contains: v1.3.5-rc1^0


The osstest service seems to be building libvirt commit:
commit 6ec319b84f67d72bf59fe7e0fd41d88ee9c393c7
Author: John Ferlan 

   logical: Clean up allocation when building regex on the fly

git describe: v1.3.1-92-g6ec319b contains: v1.3.2-rc1~262

which used gnulib from before the commit that broke it.

Jan

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 4/4] util: Make failure to get supplementary group list for a uid non-fatal

2016-06-20 Thread John Ferlan


On 06/17/2016 09:44 AM, Peter Krempa wrote:
> Since introduction of the DAC security driver we've documented that
> seclabels with a leading + can be used with numerical uid. This would
> not work though with the rest of libvirt if the uid was not actually
> used in the system as we'd fail when trying to get a list of
> supplementary groups for the given uid. Since a uid without entry in
> /etc/passwd (or other user database) will not have any supplementary
> groups we can treat the failure to obtain them as such.
> 
> This patch modifies virGetGroupList to not report the error for missing
> users and makes it return an empty list or just the group specified in
> @gid.
> 
> All callers will grand less permissions in case of failure and thus this
> change is safe.

"grand less"?  did you mean "gain less"?


ACK series (just typed out loud below)

John
> ---
>  src/util/virutil.c | 31 ---
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index 392091b..60da17b 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -1120,29 +1120,30 @@ virGetGroupID(const char *group, gid_t *gid)
> 
>  /* Compute the list of primary and supplementary groups associated
>   * with @uid, and including @gid in the list (unless it is -1),
> - * storing a malloc'd result into @list. Return the size of the list
> - * on success, or -1 on failure with error reported and errno set. May
> - * not be called between fork and exec. */
> + * storing a malloc'd result into @list. If uid is -1 or doesn't exist in the
> + * system database querying of the supplementary groups is skipped.
> + *
> + * Returns the size of the list on success, or -1 on failure with error
> + * reported and errno set. May not be called between fork and exec.
> + * */
>  int
>  virGetGroupList(uid_t uid, gid_t gid, gid_t **list)
>  {
> -int ret = -1;
> +int ret = 0;
>  char *user = NULL;
>  gid_t primary;
> 
>  *list = NULL;
> -if (uid == (uid_t)-1)
> -return 0;
> 
> -if (virGetUserEnt(uid, &user, &primary, NULL, NULL, false) < 0)
> -return -1;
> -
> -ret = mgetgroups(user, primary, list);
> -if (ret < 0) {
> -sa_assert(!*list);
> -virReportSystemError(errno,
> - _("cannot get group list for '%s'"), user);
> -goto cleanup;
> +/* invalid users have no supplementary groups */
> +if (uid != (uid_t)-1 &&
> +virGetUserEnt(uid, &user, &primary, NULL, NULL, true) >= 0) {
> +if ((ret = mgetgroups(user, primary, list)) < 0) {
> +virReportSystemError(errno,
> + _("cannot get group list for '%s'"), user);
> +ret = -1;
> +goto cleanup;
> +}
>  }

Playing the "what if" game here.  If for some reason uid == -1 OR
virGetUserEnt fails, then

gid - still to be determined
ret = 0

> 
>  if (gid != (gid_t)-1) {
> 

If we enter this "if", then the for loop will exit immediately and the
VIR_APPEND_ELEMENT will append that gid onto *list which is IIRC what we
want. Then ret will be set to 1 (i) and we return. Otherwise if gid ==
-1, then we return 0, which is still fine.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 1/4] tools: virt-login-shell: Fix group list bounds checking

2016-06-20 Thread Pavel Hrdina
On Fri, Jun 17, 2016 at 03:44:09PM +0200, Peter Krempa wrote:
> The list certainly isn't zero terminated and it would isallow usage of

s/isallow/disallow/

> group 'root'. Pass in the array size and match against it.
> ---
>  tools/virt-login-shell.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 2/4] tools: virt-login-shell: Fix cut'n'paste mistake in error message

2016-06-20 Thread Pavel Hrdina
On Fri, Jun 17, 2016 at 03:44:10PM +0200, Peter Krempa wrote:
> Whine about 'allowed_users' having wrong format rather than 'shell'
> ---
>  tools/virt-login-shell.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] util: fix a typo

2016-06-20 Thread Chen Hanxiao
From: Chen Hanxiao 

s/succcess/success

Signed-off-by: Chen Hanxiao 
---
 src/util/virfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 9d460b9..f47bf39 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -406,7 +406,7 @@ int virFileLock(int fd, bool shared, off_t start, off_t 
len, bool waitForLock)
  * NB the lock will also be released if any open file descriptor
  * pointing to the same file as @fd is closed
  *
- * Returns 0 on succcess, or -errno on error
+ * Returns 0 on success, or -errno on error
  */
 int virFileUnlock(int fd, off_t start, off_t len)
 {
-- 
1.8.3.1


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] docs: virsh: Added note for the dump command

2016-06-20 Thread Martin Kletzander

On Mon, Jun 20, 2016 at 01:34:28PM +0200, jsuch...@redhat.com wrote:

From: Jaroslav Suchanek 



Feel free to fix your git send-email settings if you used that to send
the patch, or otherwise fix your MUA or whatever you used.


Crash dump in a old kvmdump format is being obsolete and cannot be loaded and


s/a old/an old/ or just remove the 'a'.


processed by crash utility since its version 6.1.0. A --memory-only option is
required in order to produce valid ELF file which can be later processed by the
crash utility. A new note is added to the dump command description.
---
tools/virsh.pod | 5 +
1 file changed, 5 insertions(+)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 98fed76..8e3ba69 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1355,6 +1355,11 @@ B command. I<--verbose> displays the progress of 
dump.
NOTE: Some hypervisors may require the user to manually ensure proper
permissions on file and path specified by argument I.

+NOTE: Crash dump in a old kvmdump format is being obsolete and cannot be loaded


Same here.  Since that is trivial, I'll fix that and push the patch.
Congratulations on your first libvirt patch!


+and processed by crash utility since its version 6.1.0. A --memory-only option
+is required in order to produce valid ELF file which can be later processed by
+the crash utility.
+
=item B I [I<--inactive>] [I<--security-info>]
[I<--update-cpu>] [I<--migratable>]

--
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


signature.asc
Description: Digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] util: fix a typo

2016-06-20 Thread Andrea Bolognani
On Mon, 2016-06-20 at 19:52 +0800, Chen Hanxiao wrote:
> From: Chen Hanxiao 
> 
> s/succcess/success
> 
> Signed-off-by: Chen Hanxiao 
> ---
>  src/util/virfile.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index 9d460b9..f47bf39 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -406,7 +406,7 @@ int virFileLock(int fd, bool shared, off_t start, off_t 
> len, bool waitForLock)
>   * NB the lock will also be released if any open file descriptor
>   * pointing to the same file as @fd is closed
>   *
> - * Returns 0 on succcess, or -errno on error
> + * Returns 0 on success, or -errno on error
>   */
>  int virFileUnlock(int fd, off_t start, off_t len)
>  {

ACK and pushed, thanks! :)

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/4] Move ccwaddrs and pciaddrs to domainDef

2016-06-20 Thread Cole Robinson
On 06/19/2016 08:18 PM, Tomasz Flendrich wrote:
> This patch depends on another one, because it was created on top
> of the changes in the other one. Link to the dependency:
> https://www.redhat.com/archives/libvir-list/2016-June/msg01227.html
> 
> This is the next patch of the ongoing process of abstracting device
> address generation.
> 
> In this patch, addres sets are  moved from QEMU's (ccw and pci)
> and bhyve's (pci only) private data to domainDef. In the future,
> it's likely that more hypervisors will add the feature of explicitly
> specifying the device addresses, so handling the addresses should be
> made more generic.
> 

Apologies if I'm missing something, I didn't look too closely at this series,
however have you seen this thread?

http://www.redhat.com/archives/libvir-list/2016-May/msg01071.html

My understanding of the current code is that the cached vioserial/ccw/pciaddrs
lists in qemu aren't actually required... they were at one point to handle
older qemu, but we dropped that support. Maybe you can pick up my patches and
finish off dropping of pciaddrs and ccwaddrs? I suspect the pciaddrs cache in
bhyve can be dropped as well, I don't think it was ever strictly required, the
code just followed the qemu example

That said I think it makes sense in general to move this generic stuff out of
qemu since it's generic code as you say, but better to remove the obsolete
stuff first IMO

Thanks,
Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] conf: Fix label name in virDomainGraphicsListensParseXML

2016-06-20 Thread Peter Krempa
Use 'cleanup' since it's also used on success.
---
 src/conf/domain_conf.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0b642a1..f208682 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11136,20 +11136,20 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 /* parse the  subelements for graphics types that support it */
 nListens = virXPathNodeSet("./listen", ctxt, &listenNodes);
 if (nListens < 0)
-goto error;
+goto cleanup;

 if (nListens > 0) {
 size_t i;

 if (VIR_ALLOC_N(def->listens, nListens) < 0)
-goto error;
+goto cleanup;

 for (i = 0; i < nListens; i++) {
 if (virDomainGraphicsListenDefParseXML(&def->listens[i], def,
listenNodes[i],
i == 0 ? node : NULL,
flags) < 0)
-goto error;
+goto cleanup;

 def->nListens++;
 }
@@ -11177,7 +11177,7 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
  *  element. */
 if (def->nListens == 0) {
 if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0)
-goto error;
+goto cleanup;
 } else {
 virDomainGraphicsListenDefPtr glisten = &def->listens[0];

@@ -11195,7 +11195,7 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 }

 ret = 0;
- error:
+ cleanup:
 virDomainGraphicsListenDefClear(&newListen);
 VIR_FREE(listenNodes);
 VIR_FREE(socketPath);
-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/2] Fix leak and labels in virDomainGraphicsListensParseXML

2016-06-20 Thread Peter Krempa
Peter Krempa (2):
  conf: Fix memory leak in graphics XML parser
  conf: Fix label name in virDomainGraphicsListensParseXML

 src/conf/domain_conf.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/2] conf: Fix memory leak in graphics XML parser

2016-06-20 Thread Peter Krempa
When loading status XMLs with following graphics definition:

  


  

libvirtd would leak a few bytes:

10 bytes in 1 blocks are definitely lost in loss record 71 of 1,127
   at 0x4C2C000: malloc (vg_replace_malloc.c:299)
   by 0x6789298: xmlStrndup (in /usr/lib64/libxml2.so.2.9.4)
   by 0x552AB0A: virXMLPropString (virxml.c:479)
   by 0x5539536: virDomainGraphicsListensParseXML (domain_conf.c:11171)
   by 0x553DD5E: virDomainGraphicsDefParseXMLSpice (domain_conf.c:11414)
   by 0x553DD5E: virDomainGraphicsDefParseXML (domain_conf.c:11749)
   by 0x5566061: virDomainDefParseXML (domain_conf.c:16939)
   by 0x556953F: virDomainObjParseXML (domain_conf.c:17348)
   by 0x556953F: virDomainObjParseNode (domain_conf.c:17513)
   by 0x5569902: virDomainObjParseFile (domain_conf.c:17532)
   by 0x5571E02: virDomainObjListLoadStatus (virdomainobjlist.c:514)
   by 0x5571E02: virDomainObjListLoadAllConfigs (virdomainobjlist.c:596)
   by 0x26E0BDC8: qemuStateInitialize (qemu_driver.c:911)
   by 0x55B1FDB: virStateInitialize (libvirt.c:770)
   by 0x122039: daemonRunStateInit (libvirtd.c:960)
---
There might be some other for me invisible bug in the logic of handling of the
glisten definition which might make this disappear too, but I'm not really into
this code.

 src/conf/domain_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb6f58d..0b642a1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11190,13 +11190,13 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 newListen.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) {
 virDomainGraphicsListenDefClear(glisten);
 *glisten = newListen;
+memset(&newListen, 0, sizeof(newListen));
 }
 }

 ret = 0;
  error:
-if (ret < 0)
-virDomainGraphicsListenDefClear(&newListen);
+virDomainGraphicsListenDefClear(&newListen);
 VIR_FREE(listenNodes);
 VIR_FREE(socketPath);
 ctxt->node = save;
-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh: introduce name-uuid for list command

2016-06-20 Thread Peter Krempa
On Mon, Jun 20, 2016 at 19:22:45 +0800, Chen Hanxiao wrote:
> 
> At 2016-06-15 17:36:05, "Chen Hanxiao"  wrote:
> >From: Chen Hanxiao 
> >
> >This patch will show both name and UUID of domain:
> >
> > IdName   State  UUID
> > ---
> >  3 f23running
> > 918f1dd6-b19f-412b-ba17-d113bad89af8
> >
> >Signed-off-by: Chen Hanxiao 
> >---
> 
> ping?

Jan already provided a review. I agree with his view. Allowing both
--name --uuid is better than the new argument.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] gnulib and 32-bit libvirt build, rpl_canonicalize_file_name

2016-06-20 Thread Ian Jackson
Ján Tomko writes ("Re: [libvirt] gnulib and 32-bit libvirt build, 
rpl_canonicalize_file_name"):
> This has been fixed in gnulib already:
> http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=246b3b2
> commit 246b3b28808ee5f4664be674dce573af9497fc7a
> Author: Eric Blake 
> CommitDate: 2016-05-27 14:04:35 -0600
> 
> canonicalize: Fix broken probe for realpath.

Great, thanks.

> Pulled into libvirt by:
> commit 0ebd0b19d35b93eeea9d49318d7a69e147da
> Author: Eric Blake 
> CommitDate: 2016-05-27 14:06:45 -0600
> 
> maint: update to latest gnulib
> 
> Fix a regression in checking for realpath (which caused link
> failures regarding duplicate rpl_canonicalize_file_name), and
> fix the mingw build regarding unsetenv.
> 
> * .gnulib: Update to latest.
> 
> Signed-off-by: Eric Blake 

Right.

> The osstest service seems to be building libvirt commit:
> commit 6ec319b84f67d72bf59fe7e0fd41d88ee9c393c7
> Author: John Ferlan 
> 
> logical: Clean up allocation when building regex on the fly
> 
> git describe: v1.3.1-92-g6ec319b contains: v1.3.2-rc1~262
> 
> which used gnulib from before the commit that broke it.

OK, great.  Sorry for the noise.

Thanks,
Ian.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v2 1/7] domain_conf: Validate redirdev after parsing

2016-06-20 Thread Michal Privoznik
On 20.06.2016 10:32, Ján Tomko wrote:
> On Fri, Jun 10, 2016 at 05:32:55PM +0200, Michal Privoznik wrote:
>> There's currently just one limitation: redirdevs that want to go
>> on USB bus require a USB controller, surprisingly.
>> At the same time, since I'm using virDomainDefHasUSB() in this
>> new validator function, it has to be moved a few lines up and
>> also its header needed to be changed a bit: it is now taking a
>> const pointer to domain def since it's not changing anything in
>> there.
>>
>> Signed-off-by: Michal Privoznik 
>> ---
>> src/conf/domain_conf.c | 56
>> --
>> 1 file changed, 32 insertions(+), 24 deletions(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 85f6e31..c75279d 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -4567,14 +4567,45 @@ virDomainDiskDefValidate(const
>> virDomainDiskDef *disk)
>> return 0;
>> }
>>
>> +static bool
>> +virDomainDefHasUSB(const virDomainDef *def)
>> +{
>> +size_t i;
>> +
>> +for (i = 0; i < def->ncontrollers; i++) {
>> +if (def->controllers[i]->type ==
>> VIR_DOMAIN_CONTROLLER_TYPE_USB &&
>> +def->controllers[i]->model !=
>> VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE)
>> +return true;
>> +}
> 
> This function returns false either if there is a model='none' USB
> controller or if there is none at all,

But there's an implicit controlled being added after domain XML is
parsed (if none was provided in the XML), unless this behaviour has been
suppressed by model='none'.

> 
>> +
>> +return false;
>> +}
>> +
> 
>> @@ -17060,14 +17090,6 @@ virDomainDefParseXML(xmlDocPtr xml,
>> if (!redirdev)
>> goto error;
>>
>> -if (redirdev->bus == VIR_DOMAIN_REDIRDEV_BUS_USB && usb_none) {
>> - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> -_("Can't add redirected USB device: "
>> -  "USB is disabled for this domain"));
>> -virDomainRedirdevDefFree(redirdev);
> 
> but this error was only reported for model="none'.
> 
> This broke virt-manager's test:
> https://ci.centos.org/job/virt-manager-test/systems=libvirt-fedora-rawhide/1363/console

I don't see the problem. Virt-manager relied on a bug and I've fixed it.
I mean, what is happening here is: virt-manager tries to open a test
connection whilst providing its own test driver state XML. This big XML
has domain XMLs too. These are missing usb controllers and since we are
not adding implicit ones in post parse callback (there are none defined
for the test driver), domains really are missing USB controllers and
thus USB bus. It's just our buggy behaviour that caused virt-manager to
work by chance.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 0/2] Fix leak and labels in virDomainGraphicsListensParseXML

2016-06-20 Thread Pavel Hrdina
ACK series

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 4/7] virnetsockettest: fix error messages

2016-06-20 Thread Ján Tomko
---
 tests/virnetsockettest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 8cd8ede..4d78d27 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -271,7 +271,7 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 }
 
 if (STRNEQ(virNetSocketRemoteAddrString(csock), "127.0.0.1;0")) {
-VIR_DEBUG("Unexpected local address");
+VIR_DEBUG("Unexpected remote address");
 goto cleanup;
 }
 
@@ -293,7 +293,7 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 }
 
 if (STRNEQ(virNetSocketRemoteAddrString(ssock), "127.0.0.1;0")) {
-VIR_DEBUG("Unexpected local address");
+VIR_DEBUG("Unexpected remote address");
 goto cleanup;
 }
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/7] Fix SASL authentication regression

2016-06-20 Thread Ján Tomko
Introduced by commit 9b45c9f, released in v1.3.5.

https://bugzilla.redhat.com/show_bug.cgi?id=1345743

Ján Tomko (7):
  Revert "virnetsocket: Provide socket address format in a more standard
form"
  Introduce virNetSocketRemoteAddrStringURI
  Introduce virNetServerClientRemoteAddrStringURI
  virnetsockettest: fix error messages
  virNetSocket: rename AddrStr to AddrStrSASL
  Add SASL to virNetSocket{Local,Remote}AddrString
  Rename virNetServerClient*AddrString

 daemon/remote.c  | 13 ++---
 src/libvirt_remote.syms  | 10 ++
 src/remote/remote_driver.c   |  7 ---
 src/rpc/virnetclient.c   | 14 ++
 src/rpc/virnetclient.h   |  2 --
 src/rpc/virnetserver.c   |  2 +-
 src/rpc/virnetserverclient.c | 21 +++--
 src/rpc/virnetserverclient.h |  7 +++
 src/rpc/virnetsocket.c   | 41 +++--
 src/rpc/virnetsocket.h   |  7 +++
 tests/virnetsockettest.c | 26 ++
 11 files changed, 61 insertions(+), 89 deletions(-)

-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 2/7] Introduce virNetSocketRemoteAddrStringURI

2016-06-20 Thread Ján Tomko
Add a test case to virnetsockettest.
---
 src/libvirt_remote.syms  |  1 +
 src/rpc/virnetsocket.c   | 10 ++
 src/rpc/virnetsocket.h   |  1 +
 tests/virnetsockettest.c | 10 ++
 4 files changed, 22 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 1a88fff..f3cf65d 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -227,6 +227,7 @@ virNetSocketPreExecRestart;
 virNetSocketRead;
 virNetSocketRecvFD;
 virNetSocketRemoteAddrString;
+virNetSocketRemoteAddrStringURI;
 virNetSocketRemoveIOCallback;
 virNetSocketSendFD;
 virNetSocketSetBlocking;
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index d909b94..f10b62b 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -87,6 +87,7 @@ struct _virNetSocket {
 virSocketAddr remoteAddr;
 char *localAddrStr;
 char *remoteAddrStr;
+char *remoteAddrStrURI;
 
 #if WITH_GNUTLS
 virNetTLSSessionPtr tlsSession;
@@ -269,6 +270,10 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr 
localAddr,
 !(sock->remoteAddrStr = virSocketAddrFormatFull(remoteAddr, true, 
";")))
 goto error;
 
+if (remoteAddr &&
+!(sock->remoteAddrStrURI = virSocketAddrFormatFull(remoteAddr, true, 
NULL)))
+goto error;
+
 sock->client = isClient;
 
 PROBE(RPC_SOCKET_NEW,
@@ -1204,6 +1209,7 @@ void virNetSocketDispose(void *obj)
 
 VIR_FREE(sock->localAddrStr);
 VIR_FREE(sock->remoteAddrStr);
+VIR_FREE(sock->remoteAddrStrURI);
 }
 
 
@@ -1465,6 +1471,10 @@ const char *virNetSocketRemoteAddrString(virNetSocketPtr 
sock)
 return sock->remoteAddrStr;
 }
 
+const char *virNetSocketRemoteAddrStringURI(virNetSocketPtr sock)
+{
+return sock->remoteAddrStrURI;
+}
 
 #if WITH_GNUTLS
 static ssize_t virNetSocketTLSSessionWrite(const char *buf,
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index 5de3d92..25ca14e 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -150,6 +150,7 @@ bool virNetSocketHasPendingData(virNetSocketPtr sock);
 
 const char *virNetSocketLocalAddrString(virNetSocketPtr sock);
 const char *virNetSocketRemoteAddrString(virNetSocketPtr sock);
+const char *virNetSocketRemoteAddrStringURI(virNetSocketPtr sock);
 
 int virNetSocketListen(virNetSocketPtr sock, int backlog);
 int virNetSocketAccept(virNetSocketPtr sock,
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 9df90a9..8cd8ede 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -275,6 +275,11 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 goto cleanup;
 }
 
+if (STRNEQ(virNetSocketRemoteAddrStringURI(csock), "127.0.0.1:0")) {
+VIR_DEBUG("Unexpected remote address");
+goto cleanup;
+}
+
 
 if (virNetSocketAccept(lsock, &ssock) < 0) {
 VIR_DEBUG("Unexpected client socket missing");
@@ -292,6 +297,11 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 goto cleanup;
 }
 
+if (STRNEQ(virNetSocketRemoteAddrStringURI(ssock), "127.0.0.1:0")) {
+VIR_DEBUG("Unexpected remote address");
+goto cleanup;
+}
+
 
 ret = 0;
 
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 7/7] Rename virNetServerClient*AddrString

2016-06-20 Thread Ján Tomko
Add SASL at the end to make the format obvious.
---
 daemon/remote.c  | 4 ++--
 src/libvirt_remote.syms  | 4 ++--
 src/rpc/virnetserverclient.c | 4 ++--
 src/rpc/virnetserverclient.h | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index ea4753f..5ee82bb 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3028,8 +3028,8 @@ remoteDispatchAuthSaslInit(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 
 sasl = virNetSASLSessionNewServer(saslCtxt,
   "libvirt",
-  
virNetServerClientLocalAddrString(client),
-  
virNetServerClientRemoteAddrString(client));
+  
virNetServerClientLocalAddrStringSASL(client),
+  
virNetServerClientRemoteAddrStringSASL(client));
 if (!sasl)
 goto authfail;
 
diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 3858f4d..a6192ef 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -139,12 +139,12 @@ virNetServerClientInitKeepAlive;
 virNetServerClientIsClosed;
 virNetServerClientIsLocal;
 virNetServerClientIsSecure;
-virNetServerClientLocalAddrString;
+virNetServerClientLocalAddrStringSASL;
 virNetServerClientNeedAuth;
 virNetServerClientNew;
 virNetServerClientNewPostExecRestart;
 virNetServerClientPreExecRestart;
-virNetServerClientRemoteAddrString;
+virNetServerClientRemoteAddrStringSASL;
 virNetServerClientRemoteAddrStringURI;
 virNetServerClientRemoveFilter;
 virNetServerClientSendMessage;
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 5aa7634..39fe860 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -903,7 +903,7 @@ void virNetServerClientSetDispatcher(virNetServerClientPtr 
client,
 }
 
 
-const char *virNetServerClientLocalAddrString(virNetServerClientPtr client)
+const char *virNetServerClientLocalAddrStringSASL(virNetServerClientPtr client)
 {
 if (!client->sock)
 return NULL;
@@ -911,7 +911,7 @@ const char 
*virNetServerClientLocalAddrString(virNetServerClientPtr client)
 }
 
 
-const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client)
+const char *virNetServerClientRemoteAddrStringSASL(virNetServerClientPtr 
client)
 {
 if (!client->sock)
 return NULL;
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index bb9c937..c243a68 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -138,8 +138,8 @@ bool virNetServerClientCheckKeepAlive(virNetServerClientPtr 
client,
   virNetMessagePtr msg);
 int virNetServerClientStartKeepAlive(virNetServerClientPtr client);
 
-const char *virNetServerClientLocalAddrString(virNetServerClientPtr client);
-const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client);
+const char *virNetServerClientLocalAddrStringSASL(virNetServerClientPtr 
client);
+const char *virNetServerClientRemoteAddrStringSASL(virNetServerClientPtr 
client);
 const char *virNetServerClientRemoteAddrStringURI(virNetServerClientPtr 
client);
 
 int virNetServerClientSendMessage(virNetServerClientPtr client,
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 5/7] virNetSocket: rename AddrStr to AddrStrSASL

2016-06-20 Thread Ján Tomko
Make it more obvious that these are in the SASL format.
---
 src/rpc/virnetsocket.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index f10b62b..00dc417 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -85,8 +85,8 @@ struct _virNetSocket {
 
 virSocketAddr localAddr;
 virSocketAddr remoteAddr;
-char *localAddrStr;
-char *remoteAddrStr;
+char *localAddrStrSASL;
+char *remoteAddrStrSASL;
 char *remoteAddrStrURI;
 
 #if WITH_GNUTLS
@@ -263,11 +263,11 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr 
localAddr,
 
 
 if (localAddr &&
-!(sock->localAddrStr = virSocketAddrFormatFull(localAddr, true, ";")))
+!(sock->localAddrStrSASL = virSocketAddrFormatFull(localAddr, true, 
";")))
 goto error;
 
 if (remoteAddr &&
-!(sock->remoteAddrStr = virSocketAddrFormatFull(remoteAddr, true, 
";")))
+!(sock->remoteAddrStrSASL = virSocketAddrFormatFull(remoteAddr, true, 
";")))
 goto error;
 
 if (remoteAddr &&
@@ -279,7 +279,7 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr 
localAddr,
 PROBE(RPC_SOCKET_NEW,
   "sock=%p fd=%d errfd=%d pid=%lld localAddr=%s, remoteAddr=%s",
   sock, fd, errfd, (long long) pid,
-  NULLSTR(sock->localAddrStr), NULLSTR(sock->remoteAddrStr));
+  NULLSTR(sock->localAddrStrSASL), NULLSTR(sock->remoteAddrStrSASL));
 
 return sock;
 
@@ -1207,8 +1207,8 @@ void virNetSocketDispose(void *obj)
 
 virProcessAbort(sock->pid);
 
-VIR_FREE(sock->localAddrStr);
-VIR_FREE(sock->remoteAddrStr);
+VIR_FREE(sock->localAddrStrSASL);
+VIR_FREE(sock->remoteAddrStrSASL);
 VIR_FREE(sock->remoteAddrStrURI);
 }
 
@@ -1463,12 +1463,12 @@ int virNetSocketSetBlocking(virNetSocketPtr sock,
 
 const char *virNetSocketLocalAddrString(virNetSocketPtr sock)
 {
-return sock->localAddrStr;
+return sock->localAddrStrSASL;
 }
 
 const char *virNetSocketRemoteAddrString(virNetSocketPtr sock)
 {
-return sock->remoteAddrStr;
+return sock->remoteAddrStrSASL;
 }
 
 const char *virNetSocketRemoteAddrStringURI(virNetSocketPtr sock)
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/7] Revert "virnetsocket: Provide socket address format in a more standard form"

2016-06-20 Thread Ján Tomko
This partially reverts commit 9b45c9f049a7e9b6c1abfa6988b63b760714e169.

It changed the default format of socket address from the one SASL
requires, but did not adjust all the callers.

It also removed the test coverage for it.

Revert most of the changes except the virSocketAddrFormatFull support
for URI-formatted strings.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1345743 while
reverting the format used by virt-admin's client-info command from
the URI one to the SASL one.

https://bugzilla.redhat.com/show_bug.cgi?id=1345743
---
 daemon/remote.c  | 13 ++---
 src/remote/remote_driver.c   |  7 ---
 src/rpc/virnetclient.c   | 10 --
 src/rpc/virnetclient.h   |  2 --
 src/rpc/virnetserverclient.c | 13 -
 src/rpc/virnetserverclient.h |  2 --
 src/rpc/virnetsocket.c   | 17 ++---
 src/rpc/virnetsocket.h   |  2 --
 tests/virnetsockettest.c | 10 +-
 9 files changed, 9 insertions(+), 67 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 4e2aff8..ea4753f 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3016,8 +3016,6 @@ remoteDispatchAuthSaslInit(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 virNetSASLSessionPtr sasl = NULL;
 struct daemonClientPrivate *priv =
 virNetServerClientGetPrivateData(client);
-char *localAddr = NULL;
-char *remoteAddr = NULL;
 
 virMutexLock(&priv->lock);
 
@@ -3028,17 +3026,10 @@ remoteDispatchAuthSaslInit(virNetServerPtr server 
ATTRIBUTE_UNUSED,
 goto authfail;
 }
 
-localAddr = virNetServerClientLocalAddrFormatSASL(client);
-remoteAddr = virNetServerClientRemoteAddrFormatSASL(client);
-
 sasl = virNetSASLSessionNewServer(saslCtxt,
   "libvirt",
-  localAddr,
-  remoteAddr);
-
-VIR_FREE(localAddr);
-VIR_FREE(remoteAddr);
-
+  
virNetServerClientLocalAddrString(client),
+  
virNetServerClientRemoteAddrString(client));
 if (!sasl)
 goto authfail;
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 84b6d58..0315c6e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3809,8 +3809,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data 
*priv,
 sasl_callback_t *saslcb = NULL;
 int ret = -1;
 const char *mechlist;
-char *localAddr = NULL;
-char *remoteAddr = NULL;
 virNetSASLContextPtr saslCtxt;
 virNetSASLSessionPtr sasl = NULL;
 struct remoteAuthInteractState state;
@@ -3829,9 +3827,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data 
*priv,
 saslcb = NULL;
 }
 
-localAddr = virNetClientLocalAddrFormatSASL(priv->client);
-remoteAddr = virNetClientRemoteAddrFormatSASL(priv->client);
-
 /* Setup a handle for being a client */
 if (!(sasl = virNetSASLSessionNewClient(saslCtxt,
 "libvirt",
@@ -4019,8 +4014,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data 
*priv,
 
  cleanup:
 VIR_FREE(serverin);
-VIR_FREE(localAddr);
-VIR_FREE(remoteAddr);
 
 remoteAuthInteractStateClear(&state, true);
 VIR_FREE(saslcb);
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 3d59990..9c0d190 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -954,16 +954,6 @@ const char *virNetClientRemoteAddrString(virNetClientPtr 
client)
 return virNetSocketRemoteAddrString(client->sock);
 }
 
-char *virNetClientLocalAddrFormatSASL(virNetClientPtr client)
-{
-return virNetSocketLocalAddrFormatSASL(client->sock);
-}
-
-char *virNetClientRemoteAddrFormatSASL(virNetClientPtr client)
-{
-return virNetSocketRemoteAddrFormatSASL(client->sock);
-}
-
 #if WITH_GNUTLS
 int virNetClientGetTLSKeySize(virNetClientPtr client)
 {
diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h
index 4b78677..38f929c 100644
--- a/src/rpc/virnetclient.h
+++ b/src/rpc/virnetclient.h
@@ -123,8 +123,6 @@ bool virNetClientIsOpen(virNetClientPtr client);
 
 const char *virNetClientLocalAddrString(virNetClientPtr client);
 const char *virNetClientRemoteAddrString(virNetClientPtr client);
-char *virNetClientLocalAddrFormatSASL(virNetClientPtr client);
-char *virNetClientRemoteAddrFormatSASL(virNetClientPtr client);
 
 # ifdef WITH_GNUTLS
 int virNetClientGetTLSKeySize(virNetClientPtr client);
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index ef83507..2bc058c 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -918,19 +918,6 @@ const char 
*virNetServerClientRemoteAddrString(virNetServerClientPtr client)
 return virNetSocketRemoteAddrString(client->sock);
 }
 
-char *virNetServerClientLocalAddrFormatSASL(virNetServerClientPtr client)
-{
-if (!client->sock)
-return NULL;
-return virNe

[libvirt] [PATCH 3/7] Introduce virNetServerClientRemoteAddrStringURI

2016-06-20 Thread Ján Tomko
Use it in virNetServerClientGetInfo to switch back to using
the URI-format (separated by ':') instead of the SASL format
(separated by ';').

Also use it in the error message reported byvirNetServerAddClient.
---
 src/libvirt_remote.syms  | 1 +
 src/rpc/virnetserver.c   | 2 +-
 src/rpc/virnetserverclient.c | 8 +++-
 src/rpc/virnetserverclient.h | 1 +
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index f3cf65d..fd80e46 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -145,6 +145,7 @@ virNetServerClientNew;
 virNetServerClientNewPostExecRestart;
 virNetServerClientPreExecRestart;
 virNetServerClientRemoteAddrString;
+virNetServerClientRemoteAddrStringURI;
 virNetServerClientRemoveFilter;
 virNetServerClientSendMessage;
 virNetServerClientSetAuth;
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 4c4b144..8c8af97 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -243,7 +243,7 @@ int virNetServerAddClient(virNetServerPtr srv,
 if (srv->nclients >= srv->nclients_max) {
 virReportError(VIR_ERR_RPC,
_("Too many active clients (%zu), dropping connection 
from %s"),
-   srv->nclients_max, 
virNetServerClientRemoteAddrString(client));
+   srv->nclients_max, 
virNetServerClientRemoteAddrStringURI(client));
 goto error;
 }
 
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 2bc058c..15715a9 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -918,6 +918,12 @@ const char 
*virNetServerClientRemoteAddrString(virNetServerClientPtr client)
 return virNetSocketRemoteAddrString(client->sock);
 }
 
+const char *virNetServerClientRemoteAddrStringURI(virNetServerClientPtr client)
+{
+if (!client->sock)
+return NULL;
+return virNetSocketRemoteAddrStringURI(client->sock);
+}
 
 void virNetServerClientDispose(void *obj)
 {
@@ -1608,7 +1614,7 @@ virNetServerClientGetInfo(virNetServerClientPtr client,
 virObjectLock(client);
 *readonly = client->readonly;
 
-if (!(*sock_addr = virNetServerClientRemoteAddrString(client))) {
+if (!(*sock_addr = virNetServerClientRemoteAddrStringURI(client))) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No network socket associated with client"));
 goto cleanup;
diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h
index c8b8dc1..bb9c937 100644
--- a/src/rpc/virnetserverclient.h
+++ b/src/rpc/virnetserverclient.h
@@ -140,6 +140,7 @@ int virNetServerClientStartKeepAlive(virNetServerClientPtr 
client);
 
 const char *virNetServerClientLocalAddrString(virNetServerClientPtr client);
 const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client);
+const char *virNetServerClientRemoteAddrStringURI(virNetServerClientPtr 
client);
 
 int virNetServerClientSendMessage(virNetServerClientPtr client,
   virNetMessagePtr msg);
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 6/7] Add SASL to virNetSocket{Local, Remote}AddrString

2016-06-20 Thread Ján Tomko
Rename them to virNetSocket{Local,Remote}AddrStringSASL
to make their format more obvious.
---
 src/libvirt_remote.syms  |  4 ++--
 src/rpc/virnetclient.c   |  4 ++--
 src/rpc/virnetserverclient.c |  4 ++--
 src/rpc/virnetsocket.c   |  4 ++--
 src/rpc/virnetsocket.h   |  4 ++--
 tests/virnetsockettest.c | 12 ++--
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index fd80e46..3858f4d 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -212,7 +212,7 @@ virNetSocketHasPassFD;
 virNetSocketHasPendingData;
 virNetSocketIsLocal;
 virNetSocketListen;
-virNetSocketLocalAddrString;
+virNetSocketLocalAddrStringSASL;
 virNetSocketNewConnectCommand;
 virNetSocketNewConnectExternal;
 virNetSocketNewConnectLibSSH2;
@@ -227,7 +227,7 @@ virNetSocketNewPostExecRestart;
 virNetSocketPreExecRestart;
 virNetSocketRead;
 virNetSocketRecvFD;
-virNetSocketRemoteAddrString;
+virNetSocketRemoteAddrStringSASL;
 virNetSocketRemoteAddrStringURI;
 virNetSocketRemoveIOCallback;
 virNetSocketSendFD;
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 9c0d190..c43cd08 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -946,12 +946,12 @@ void virNetClientRemoveStream(virNetClientPtr client,
 
 const char *virNetClientLocalAddrString(virNetClientPtr client)
 {
-return virNetSocketLocalAddrString(client->sock);
+return virNetSocketLocalAddrStringSASL(client->sock);
 }
 
 const char *virNetClientRemoteAddrString(virNetClientPtr client)
 {
-return virNetSocketRemoteAddrString(client->sock);
+return virNetSocketRemoteAddrStringSASL(client->sock);
 }
 
 #if WITH_GNUTLS
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 15715a9..5aa7634 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -907,7 +907,7 @@ const char 
*virNetServerClientLocalAddrString(virNetServerClientPtr client)
 {
 if (!client->sock)
 return NULL;
-return virNetSocketLocalAddrString(client->sock);
+return virNetSocketLocalAddrStringSASL(client->sock);
 }
 
 
@@ -915,7 +915,7 @@ const char 
*virNetServerClientRemoteAddrString(virNetServerClientPtr client)
 {
 if (!client->sock)
 return NULL;
-return virNetSocketRemoteAddrString(client->sock);
+return virNetSocketRemoteAddrStringSASL(client->sock);
 }
 
 const char *virNetServerClientRemoteAddrStringURI(virNetServerClientPtr client)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 00dc417..405f5ba 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1461,12 +1461,12 @@ int virNetSocketSetBlocking(virNetSocketPtr sock,
 }
 
 
-const char *virNetSocketLocalAddrString(virNetSocketPtr sock)
+const char *virNetSocketLocalAddrStringSASL(virNetSocketPtr sock)
 {
 return sock->localAddrStrSASL;
 }
 
-const char *virNetSocketRemoteAddrString(virNetSocketPtr sock)
+const char *virNetSocketRemoteAddrStringSASL(virNetSocketPtr sock)
 {
 return sock->remoteAddrStrSASL;
 }
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index 25ca14e..ec064bb 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -148,8 +148,8 @@ void virNetSocketSetSASLSession(virNetSocketPtr sock,
 bool virNetSocketHasCachedData(virNetSocketPtr sock);
 bool virNetSocketHasPendingData(virNetSocketPtr sock);
 
-const char *virNetSocketLocalAddrString(virNetSocketPtr sock);
-const char *virNetSocketRemoteAddrString(virNetSocketPtr sock);
+const char *virNetSocketLocalAddrStringSASL(virNetSocketPtr sock);
+const char *virNetSocketRemoteAddrStringSASL(virNetSocketPtr sock);
 const char *virNetSocketRemoteAddrStringURI(virNetSocketPtr sock);
 
 int virNetSocketListen(virNetSocketPtr sock, int backlog);
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 4d78d27..cafdca9 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -249,12 +249,12 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 if (virNetSocketNewListenUNIX(path, 0700, -1, getegid(), &lsock) < 0)
 goto cleanup;
 
-if (STRNEQ(virNetSocketLocalAddrString(lsock), "127.0.0.1;0")) {
+if (STRNEQ(virNetSocketLocalAddrStringSASL(lsock), "127.0.0.1;0")) {
 VIR_DEBUG("Unexpected local address");
 goto cleanup;
 }
 
-if (virNetSocketRemoteAddrString(lsock) != NULL) {
+if (virNetSocketRemoteAddrStringSASL(lsock) != NULL) {
 VIR_DEBUG("Unexpected remote address");
 goto cleanup;
 }
@@ -265,12 +265,12 @@ static int testSocketUNIXAddrs(const void *data 
ATTRIBUTE_UNUSED)
 if (virNetSocketNewConnectUNIX(path, false, NULL, &csock) < 0)
 goto cleanup;
 
-if (STRNEQ(virNetSocketLocalAddrString(csock), "127.0.0.1;0")) {
+if (STRNEQ(virNetSocketLocalAddrStringSASL(csock), "127.0.0.1;0")) {
 VIR_DEBUG("Unexpected local address");
 goto cleanup;
 }
 
-if (

[libvirt] [PATCH 5/7] qemu: agent: Make setting of vcpus more robust

2016-06-20 Thread Peter Krempa
Documentation for the "guest-set-vcpus" command describes a proper
algorithm how to set vcpus. This patch makes the following changes:

- state of cpus that has not changed is not updated
- if the command was partially successful the command is re-tried with
  the rest of the arguments to get a proper error message
- code is more robust against mailicious guest agent
- fix testsuite to the new semantics
---
 src/qemu/qemu_agent.c  | 83 ++
 src/qemu/qemu_agent.h  |  2 ++
 src/qemu/qemu_driver.c | 13 
 tests/qemuagenttest.c  | 44 --
 4 files changed, 92 insertions(+), 50 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index cbc0995..5bd767a 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1523,16 +1523,13 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
 return ret;
 }

-/**
- * Set the VCPU state using guest agent.
- *
- * Returns -1 on error, ninfo in case everything was successful and less than
- * ninfo on a partial failure.
- */
-int
-qemuAgentSetVCPUs(qemuAgentPtr mon,
-  qemuAgentCPUInfoPtr info,
-  size_t ninfo)
+
+/* returns the value provided by the guest agent or -1 on internal error */
+static int
+qemuAgentSetVCPUsCommand(qemuAgentPtr mon,
+ qemuAgentCPUInfoPtr info,
+ size_t ninfo,
+ int *nmodified)
 {
 int ret = -1;
 virJSONValuePtr cmd = NULL;
@@ -1541,6 +1538,8 @@ qemuAgentSetVCPUs(qemuAgentPtr mon,
 virJSONValuePtr cpu = NULL;
 size_t i;

+*nmodified = 0;
+
 /* create the key data array */
 if (!(cpus = virJSONValueNewArray()))
 goto cleanup;
@@ -1552,6 +1551,12 @@ qemuAgentSetVCPUs(qemuAgentPtr mon,
 if (!(cpu = virJSONValueNewObject()))
 goto cleanup;

+/* don't set state for cpus that were not touched */
+if (!in->modified)
+continue;
+
+(*nmodified)++;
+
 if (virJSONValueObjectAppendNumberInt(cpu, "logical-id", in->id) < 0)
 goto cleanup;

@@ -1564,6 +1569,11 @@ qemuAgentSetVCPUs(qemuAgentPtr mon,
 cpu = NULL;
 }

+if (*nmodified == 0) {
+ret = 0;
+goto cleanup;
+}
+
 if (!(cmd = qemuAgentMakeCommand("guest-set-vcpus",
  "a:vcpus", cpus,
  NULL)))
@@ -1575,9 +1585,17 @@ qemuAgentSetVCPUs(qemuAgentPtr mon,
  VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
 goto cleanup;

-if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
+if (qemuAgentCheckError(cmd, reply) < 0)
+goto cleanup;
+
+/* All negative values are invalid. Return of 0 is bougs since we wouldn't
+ * call the guest agent so that 0 cpus would be set successfully. Reporting
+ * more successfuly set vcpus that we've asked for is invalid */
+if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0 ||
+ret <= 0 || ret > *nmodified) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-   _("malformed return value"));
+   _("guest agent returned malformed or invalid return 
value"));
+ret = -1;
 }

  cleanup:
@@ -1589,6 +1607,45 @@ qemuAgentSetVCPUs(qemuAgentPtr mon,
 }


+/**
+ * Set the VCPU state using guest agent.
+ *
+ * Attempts to set the guest agent state for all cpus or until a proper error 
is
+ * reported by the guest agent. This may require multiple calls.
+ *
+ * Returns -1 on error, 0 on success.
+ */
+int
+qemuAgentSetVCPUs(qemuAgentPtr mon,
+  qemuAgentCPUInfoPtr info,
+  size_t ninfo)
+{
+int rv;
+int nmodified;
+size_t i;
+
+do {
+if ((rv = qemuAgentSetVCPUsCommand(mon, info, ninfo, &nmodified)) < 0)
+return -1;
+
+/* all vcpus were set successfully */
+if (rv == nmodified)
+return 0;
+
+/* un-mark vcpus that were already set */
+for (i = 0; i < ninfo && rv > 0; i++) {
+if (!info[i].modified)
+continue;
+
+info[i].modified = false;
+rv--;
+}
+} while (1);
+
+return 0;
+}
+
+
 /* modify the cpu info structure to set the correct amount of cpus */
 int
 qemuAgentUpdateCPUInfo(unsigned int nvcpus,
@@ -1647,12 +1704,14 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
 /* unplug */
 if (cpuinfo[i].offlinable && cpuinfo[i].online) {
 cpuinfo[i].online = false;
+cpuinfo[i].modified = true;
 nonline--;
 }
 } else if (nvcpus > nonline) {
 /* plug */
 if (!cpuinfo[i].online) {
 cpuinfo[i].online = true;
+cpuinfo[i].modified = true;
 nonline++;
 }
 } else {
diff --git a/src/qemu/qemu_agent.h b/src/qem

[libvirt] [PATCH 1/7] rpcgen: Add support for generating funcs returning alloc'd typed params

2016-06-20 Thread Peter Krempa
Since it's rather tedious to write the dispatchers for functions that
return an array of typed parameters (which are rather common) let's add
some rpcgen code to generate them.
---
 src/remote/remote_protocol.x |  5 +
 src/rpc/gendispatch.pl   | 45 +++-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 0170c0c..cec6bd2 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -414,6 +414,11 @@ struct remote_domain_disk_error {
  * insert@ comment to indicate the offset in the parameter list of
  * the function to be called.
  *
+ * For cases where the API allocates memory and fills the arguments (mostly
+ * typed parameters) a similar comment indicates the type and offset
+ * of the variable to be filled with the count of returned elements.
+ * alloc@@unsigned int@
+ *
  * Dynamic opaque and remote_nonnull_string arrays can be annotated with an
  * optional typecast */

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 5564b2e..173189c 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -862,6 +862,25 @@ elsif ($mode eq "server") {
 $single_ret_var = $2;
 $single_ret_by_ref = 0;
 $single_ret_check = " == NULL";
+} elsif ($ret_member =~ m/^remote_typed_param 
(\S+)<(\S+)>;\s*\/\*\s*alloc@(\d+)@([^@]+)@(\d+)\s*\*\//) {
+push(@vars_list, "virTypedParameterPtr $1 = NULL");
+push(@vars_list, "$4 $1_len = 0");
+
+$single_ret_by_ref = 1;
+$single_ret_var = undef;
+
+splice(@args_list, int($3), 0, "&$1");
+splice(@args_list, int($5), 0, "&$1_len");
+
+push(@ret_list, "if (virTypedParamsSerialize($1, 
$1_len,\n" .
+"
(virTypedParameterRemotePtr *) &ret->$1.$1_val,\n" .
+"
&ret->$1.$1_len,\n" .
+"
VIR_TYPED_PARAM_STRING_OKAY) < 0)\n" .
+"goto cleanup;\n");
+
+push(@free_list, "virTypedParamsFree($1, $1_len);");
+push(@free_list_on_error, 
"virTypedParamsRemoteFree((virTypedParameterRemotePtr) 
ret->params.params_val,\n" .
+  "
 ret->params.params_len);\n");
 } elsif ($ret_member =~ m/^(\/)?\*/) {
 # ignore comments
 } else {
@@ -1422,6 +1441,7 @@ elsif ($mode eq "client") {
 my $modern_ret_as_list = 0;
 my $modern_ret_struct_name = "undefined";
 my $modern_ret_var_type = "undefined";
+my @custom_error_cleanup = ();

 if ($rettype ne "void" and
 scalar(@{$call->{ret_members}}) > 1) {
@@ -1519,6 +1539,23 @@ elsif ($mode eq "client") {
 $single_ret_var = "vir${type_name}Ptr rv = NULL";
 $single_ret_type = "vir${type_name}Ptr";
 }
+} elsif ($ret_member =~ m/^remote_typed_param 
(\S+)<(\S+)>;\s*\/\*\s*alloc@(\d+)@([^@]+)@(\d+)\s*\*\//) {
+# handle self allocating arrays of typed parameters
+splice(@args_list, int($3), 0, ("virTypedParameterPtr 
*$1"));
+splice(@args_list, int($5), 0, ("$4 *n$1"));
+push(@vars_list, "virTypedParameterPtr ret_params = NULL");
+push(@vars_list, "int ret_nparams = 0");
+# virTypedParamsDeserialize allocates the array if @params 
is null
+push(@ret_list2, "if 
(virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.$1.$1_val,\n" .
+ "  
ret.$1.$1_len,\n" .
+ "  $2,\n" 
.
+ "  
&ret_params,\n" .
+ "  
&ret_nparams) < 0)\n" .
+ "goto cleanup;\n");
+push(@ret_list2, "*$1 = ret_params;");
+push(@ret_list2, "*n$1 = ret_nparams;");
+push(@custom_error_cleanup, 
"virTypedParamsFree(ret_params, ret_nparams);\n");
+$single_ret_cleanup = 1;
 } elsif ($ret_member =~ m/^remote_typed_param 
(\S+)<(\S+)>;\s*\/\*\s*insert@(\d+)\s*\*\//) {
 splice(@args_list, int($3), 0, ("virTypedParameterPtr 
$1"));
 push(@ret_list2, "if 
(virTypedParamsDeserialize((virTypedParameterRemotePtr) ret.$1.$

[libvirt] [PATCH 0/7] Add APIs for individual vCPU state modification using the guest agent

2016-06-20 Thread Peter Krempa
As a first step, add the guest-agent part. The real hotplug stuff will follow
shortly. Please note that the setter API will be used as template for the real
stuff too.

Peter Krempa (7):
  rpcgen: Add support for generating funcs returning alloc'd typed
params
  lib: Add API to query guest vcpu info using guest agent
  lib: Add API to set individual vcpu usage in the guest via guest agent
  virsh: Add command 'guestvcpus' implementing virDomain(GS)etGuestVcpus
  qemu: agent: Make setting of vcpus more robust
  qemu: Implement virDomainGetGuestVcpus
  qemu: Implement virDomainSetGuestVcpus

 include/libvirt/libvirt-domain.h |  10 ++
 src/driver-hypervisor.h  |  14 +++
 src/libvirt-domain.c | 105 
 src/libvirt_public.syms  |   2 +
 src/qemu/qemu_agent.c|  83 +---
 src/qemu/qemu_agent.h|   2 +
 src/qemu/qemu_driver.c   | 210 ---
 src/remote/remote_driver.c   |   2 +
 src/remote/remote_protocol.x |  39 +++-
 src/remote_protocol-structs  |  18 
 src/rpc/gendispatch.pl   |  45 -
 tests/qemuagenttest.c|  44 
 tools/virsh-domain.c |  93 +
 tools/virsh.pod  |  10 ++
 14 files changed, 625 insertions(+), 52 deletions(-)

-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 4/7] virsh: Add command 'guestvcpus' implementing virDomain(GS)etGuestVcpus

2016-06-20 Thread Peter Krempa
Add a straightforward implementation for using the new APIs.
---
 tools/virsh-domain.c | 93 
 tools/virsh.pod  | 10 ++
 2 files changed, 103 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index bd6db47..ff2305f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6762,6 +6762,93 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
 return ret;
 }

+
+/*
+ * "guestvcpus" command
+ */
+static const vshCmdInfo info_guestvcpus[] = {
+{.name = "help",
+ .data = N_("query or modify state of vcpu in the guest (via agent)")
+},
+{.name = "desc",
+ .data = N_("Use the guest agent to query or set cpu state from guest's "
+"point of view")
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_guestvcpus[] = {
+VIRSH_COMMON_OPT_DOMAIN_FULL,
+{.name = "cpumap",
+ .type = VSH_OT_STRING,
+ .help = N_("number of virtual CPUs")
+},
+{.name = "enable",
+ .type = VSH_OT_BOOL,
+ .help = N_("enable cpus specified by cpumap")
+},
+{.name = "disable",
+ .type = VSH_OT_BOOL,
+ .help = N_("disable cpus specified by cpumap")
+},
+{.name = NULL}
+};
+
+static bool
+cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom;
+bool enable = vshCommandOptBool(cmd, "enable");
+bool disable = vshCommandOptBool(cmd, "disable");
+virTypedParameterPtr params = NULL;
+unsigned int nparams = 0;
+const char *cpumap = NULL;
+int state = 0;
+size_t i;
+bool ret = false;
+
+VSH_EXCLUSIVE_OPTIONS_VAR(enable, disable);
+VSH_REQUIRE_OPTION("enable", "cpumap");
+VSH_REQUIRE_OPTION("disable", "cpumap");
+
+if (vshCommandOptStringReq(ctl, cmd, "cpumap", &cpumap))
+return false;
+
+if (cpumap && !(enable | disable)) {
+vshError(ctl, _("One of options --enable or --disable is required by "
+"option --cpumap"));
+return false;
+}
+
+if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (enable)
+state = 1;
+
+if (cpumap) {
+if (virDomainSetGuestVcpus(dom, cpumap, state, 0) < 0)
+goto cleanup;
+} else {
+if (virDomainGetGuestVcpus(dom, ¶ms, &nparams, 0) < 0)
+goto cleanup;
+
+for (i = 0; i < nparams; i++) {
+char *str = vshGetTypedParamValue(ctl, ¶ms[i]);
+vshPrint(ctl, "%-15s: %s\n", params[i].field, str);
+VIR_FREE(str);
+}
+}
+
+ret = true;
+
+ cleanup:
+virTypedParamsFree(params, nparams);
+virDomainFree(dom);
+return ret;
+}
+
+
 /*
  * "iothreadinfo" command
  */
@@ -13602,5 +13689,11 @@ const vshCmdDef domManagementCmds[] = {
  .info = info_vncdisplay,
  .flags = 0
 },
+{.name = "guestvcpus",
+ .handler = cmdGuestvcpus,
+ .opts = opts_guestvcpus,
+ .info = info_guestvcpus,
+ .flags = 0
+},
 {.name = NULL}
 };
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 8e3ba69..6af1328 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2501,6 +2501,16 @@ Both I<--live> and I<--config> flags may be given if 
I is present,
 but I<--current> is exclusive.
 If no flag is specified, behavior is different depending on hypervisor.

+=item B I [[I<--enable>] | [I<--disable>]] [I]
+
+Query or change state of vCPUs from guest's point of view using the guest 
agent.
+When invoked without I the guest is queried for available guest vCPUs,
+their state and possibility to be offlined.
+
+If I is provided then one of I<--enable> or I<--disable> must be
+provided too. The desired operation is then executed on the domain.
+
+See B for I (as I).

 =item B I

-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 7/7] qemu: Implement virDomainSetGuestVcpus

2016-06-20 Thread Peter Krempa
Allow modification of specific vCPU states via the guest agent.
---
 src/qemu/qemu_driver.c | 83 ++
 1 file changed, 83 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5b96ad8..4bd8c92 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19837,6 +19837,88 @@ qemuDomainGetGuestVcpus(virDomainPtr dom,
 }


+static int
+qemuDomainSetGuestVcpus(virDomainPtr dom,
+const char *cpumap,
+int state,
+unsigned int flags)
+{
+virQEMUDriverPtr driver = dom->conn->privateData;
+virDomainObjPtr vm = NULL;
+virBitmapPtr map = NULL;
+qemuAgentCPUInfoPtr info = NULL;
+int ninfo = 0;
+size_t i;
+int ret = -1;
+
+virCheckFlags(0, -1);
+
+if (state != 0 && state != 1) {
+virReportInvalidArg(state, "%s", _("unsupported state value"));
+return -1;
+}
+
+if (virBitmapParse(cpumap, &map, 4096) < 0)
+goto cleanup;
+
+if (!(vm = qemuDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainSetGuestVcpusEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+goto cleanup;
+
+if (!qemuDomainAgentAvailable(vm, true))
+goto endjob;
+
+qemuDomainObjEnterAgent(vm);
+ninfo = qemuAgentGetVCPUs(qemuDomainGetAgent(vm), &info);
+qemuDomainObjExitAgent(vm);
+
+if (ninfo < 0)
+goto endjob;
+
+for (i = 0; i < ninfo; i++) {
+if (!virBitmapIsBitSet(map, info[i].id))
+continue;
+
+if (!state && !info[i].offlinable) {
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+   _("vCPU '%u' is not offlinable"), info[i].id);
+goto endjob;
+}
+
+info[i].online = !!state;
+info[i].modified = true;
+
+ignore_value(virBitmapClearBit(map, info[i].id));
+}
+
+if (!virBitmapIsAllClear(map)) {
+char *tmp = virBitmapFormat(map);
+virReportError(VIR_ERR_INVALID_ARG,
+   _("guest is missing vCPUs '%s'"), NULLSTR(tmp));
+VIR_FREE(tmp);
+goto endjob;
+}
+
+qemuDomainObjEnterAgent(vm);
+ret = qemuAgentSetVCPUs(qemuDomainGetAgent(vm), info, ninfo);
+qemuDomainObjExitAgent(vm);
+
+ endjob:
+qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+VIR_FREE(info);
+virBitmapFree(map);
+virDomainObjEndAPI(&vm);
+return ret;
+}
+
+
 static virHypervisorDriver qemuHypervisorDriver = {
 .name = QEMU_DRIVER_NAME,
 .connectOpen = qemuConnectOpen, /* 0.2.0 */
@@ -20049,6 +20131,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
 .domainRename = qemuDomainRename, /* 1.2.19 */
 .domainMigrateStartPostCopy = qemuDomainMigrateStartPostCopy, /* 1.3.3 */
 .domainGetGuestVcpus = qemuDomainGetGuestVcpus, /* 2.0.0 */
+.domainSetGuestVcpus = qemuDomainSetGuestVcpus, /* 2.0.0 */
 };


-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/7] lib: Add API to set individual vcpu usage in the guest via guest agent

2016-06-20 Thread Peter Krempa
To allow finer-grained control of vcpu state using guest agent this API
can be used to individually set the state of the vCPU.

This will allow to better control NUMA enabled guests and/or test
various vCPU configurations.
---
 include/libvirt/libvirt-domain.h |  5 
 src/driver-hypervisor.h  |  7 ++
 src/libvirt-domain.c | 49 
 src/libvirt_public.syms  |  1 +
 src/remote/remote_driver.c   |  1 +
 src/remote/remote_protocol.x | 15 +++-
 src/remote_protocol-structs  |  7 ++
 7 files changed, 84 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 5605a94..5b80b85 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4102,4 +4102,9 @@ int virDomainGetGuestVcpus(virDomainPtr domain,
unsigned int *nparams,
unsigned int flags);

+int virDomainSetGuestVcpus(virDomainPtr domain,
+   const char *cpumap,
+   int state,
+   unsigned int flags);
+
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 93af2b6..5cd1fdf 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1245,6 +1245,12 @@ typedef int
  unsigned int *nparams,
  unsigned int flags);

+typedef int
+(*virDrvDomainSetGuestVcpus)(virDomainPtr domain,
+ const char *cpumap,
+ int state,
+ unsigned int flags);
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;

@@ -1482,6 +1488,7 @@ struct _virHypervisorDriver {
 virDrvConnectUnregisterCloseCallback connectUnregisterCloseCallback;
 virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
 virDrvDomainGetGuestVcpus domainGetGuestVcpus;
+virDrvDomainSetGuestVcpus domainSetGuestVcpus;
 };


diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 0971a96..11f20af 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11891,3 +11891,52 @@ virDomainGetGuestVcpus(virDomainPtr domain,
 virDispatchError(domain->conn);
 return -1;
 }
+
+
+/**
+ * virDomainSetGuestVcpus:
+ * @domain: pointer to domain object
+ * @cpumap: text representation of a bitmap of vcpus to set
+ * @state: 0 to disable/1 to enable cpus described by @cpumap
+ * @flags: currently unused, callers shall pass 0
+ *
+ * Sets state of individual vcpus described by @cpumap via guest agent. Other
+ * vcpus are not modified.
+ *
+ * This API requires the VM to run. Various hypervisors or guest agent
+ * implementation may limit to operate on just 1 vCPU per call.
+ *
+ * Note that OSes (notably Linux) may require vCPU 0 to stay online to support
+ * low-level features a S3 sleep.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virDomainSetGuestVcpus(virDomainPtr domain,
+   const char *cpumap,
+   int state,
+   unsigned int flags)
+{
+VIR_DOMAIN_DEBUG(domain, "cpumap='%s' state=%x flags=%x",
+ NULLSTR(cpumap), state, flags);
+
+virResetLastError();
+
+virCheckDomainReturn(domain, -1);
+virCheckNonNullArgGoto(cpumap, error);
+
+if (domain->conn->driver->domainSetGuestVcpus) {
+int ret;
+ret = domain->conn->driver->domainSetGuestVcpus(domain, cpumap, state,
+flags);
+if (ret < 0)
+goto error;
+return ret;
+}
+
+virReportUnsupportedError();
+
+ error:
+virDispatchError(domain->conn);
+return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 30801c5..b6d2dfd 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -737,6 +737,7 @@ LIBVIRT_2.0.0 {
 virConnectStoragePoolEventRegisterAny;
 virConnectStoragePoolEventDeregisterAny;
 virDomainGetGuestVcpus;
+virDomainSetGuestVcpus;
 } LIBVIRT_1.3.3;

 #  define new API here using predicted next version number 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 6a580c6..3f9d812 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7982,6 +7982,7 @@ static virHypervisorDriver hypervisor_driver = {
 .connectUnregisterCloseCallback = remoteConnectUnregisterCloseCallback, /* 
1.3.2 */
 .domainMigrateStartPostCopy = remoteDomainMigrateStartPostCopy, /* 1.3.3 */
 .domainGetGuestVcpus = remoteDomainGetGuestVcpus, /* 2.0.0 */
+.domainSetGuestVcpus = remoteDomainSetGuestVcpus, /* 2.0.0 */
 };

 static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f72918d..d11bfdf 1006

[libvirt] [PATCH 2/7] lib: Add API to query guest vcpu info using guest agent

2016-06-20 Thread Peter Krempa
Add a rather universal API implemented via typed params that will allow
to query the guest agent for the state and possibly other aspects of
guest vcpus.
---
 include/libvirt/libvirt-domain.h |  5 
 src/driver-hypervisor.h  |  7 +
 src/libvirt-domain.c | 56 
 src/libvirt_public.syms  |  1 +
 src/remote/remote_driver.c   |  1 +
 src/remote/remote_protocol.x | 21 ++-
 src/remote_protocol-structs  | 11 
 7 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index cba4fa5..5605a94 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -4097,4 +4097,9 @@ int virDomainRename(virDomainPtr dom,
 const char *new_name,
 unsigned int flags);

+int virDomainGetGuestVcpus(virDomainPtr domain,
+   virTypedParameterPtr *params,
+   unsigned int *nparams,
+   unsigned int flags);
+
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 5ab5775..93af2b6 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1239,6 +1239,12 @@ typedef int
 (*virDrvConnectUnregisterCloseCallback)(virConnectPtr conn,
 virConnectCloseFunc cb);

+typedef int
+(*virDrvDomainGetGuestVcpus)(virDomainPtr domain,
+ virTypedParameterPtr *params,
+ unsigned int *nparams,
+ unsigned int flags);
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;

@@ -1475,6 +1481,7 @@ struct _virHypervisorDriver {
 virDrvConnectRegisterCloseCallback connectRegisterCloseCallback;
 virDrvConnectUnregisterCloseCallback connectUnregisterCloseCallback;
 virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
+virDrvDomainGetGuestVcpus domainGetGuestVcpus;
 };


diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 73ae369..0971a96 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11835,3 +11835,59 @@ virDomainInterfaceFree(virDomainInterfacePtr iface)

 VIR_FREE(iface);
 }
+
+
+/**
+ * virDomainGetGuestVcpus:
+ * @domain: pointer to domain object
+ * @params: Pointer that will be filled with an array of typed parameters
+ * @nparams: pointer filled with number of elements in @params
+ * @flags: currently unused, callers shall pass 0
+ *
+ * Queries the guest agent for state and information regarding vCPUs from
+ * guest's perspective. The reported data depends on the guest agent
+ * implementation.
+ *
+ * Reported fields stored in @params:
+ * 'vcpus': string containing bitmap representing vCPU ids as reported by the
+ *  guest
+ * 'online': string containing bitmap representing online vCPUs as reported
+ *   by the guest agent.
+ * 'offlinable': string containing bitmap representing ids of vCPUs that can be
+ *   offlined
+ *
+ * This API requires the VM to run. The caller is responsible for calling
+ * virTypedParamsFree to free memory returned in @params.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+virDomainGetGuestVcpus(virDomainPtr domain,
+   virTypedParameterPtr *params,
+   unsigned int *nparams,
+   unsigned int flags)
+{
+VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p, flags=%x",
+ params, nparams, flags);
+
+virResetLastError();
+
+virCheckDomainReturn(domain, -1);
+virCheckNonNullArgGoto(params, error);
+virCheckNonNullArgGoto(nparams, error);
+
+if (domain->conn->driver->domainGetGuestVcpus) {
+int ret;
+ret = domain->conn->driver->domainGetGuestVcpus(domain, params, 
nparams,
+flags);
+if (ret < 0)
+goto error;
+return ret;
+}
+
+virReportUnsupportedError();
+
+ error:
+virDispatchError(domain->conn);
+return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 06011ce..30801c5 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -736,6 +736,7 @@ LIBVIRT_2.0.0 {
 global:
 virConnectStoragePoolEventRegisterAny;
 virConnectStoragePoolEventDeregisterAny;
+virDomainGetGuestVcpus;
 } LIBVIRT_1.3.3;

 #  define new API here using predicted next version number 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 84b6d58..6a580c6 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7981,6 +7981,7 @@ static virHypervisorDriver hypervisor_driver = {
 .connectRegisterCloseCallback = remoteConnectRegisterCloseCallback, /* 
1.3.2 */
 .connectUnregisterCloseCallback =

[libvirt] [PATCH 6/7] qemu: Implement virDomainGetGuestVcpus

2016-06-20 Thread Peter Krempa
Allow gathering available vcpu ids, their state and offlinability via
the qemu guest agent. The maximum id was chosen arbitrarily and ought
to be enough for everybody.
---
 src/qemu/qemu_driver.c | 114 +
 1 file changed, 114 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 098840f..5b96ad8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -122,6 +122,8 @@ VIR_LOG_INIT("qemu.qemu_driver");
 #define QEMU_SCHED_MIN_QUOTA   1000LL
 #define QEMU_SCHED_MAX_QUOTA  18446744073709551LL

+#define QEMU_GUEST_VCPU_MAX_ID 4096
+
 #if HAVE_LINUX_KVM_H
 # include 
 #endif
@@ -19724,6 +19726,117 @@ static int qemuDomainRename(virDomainPtr dom,
 return ret;
 }

+
+static int
+qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
+  unsigned int *nparams,
+  qemuAgentCPUInfoPtr info,
+  int ninfo)
+{
+virTypedParameterPtr par = NULL;
+int npar = 0;
+int maxpar = 0;
+virBitmapPtr vcpus = NULL;
+virBitmapPtr online = NULL;
+virBitmapPtr offlinable = NULL;
+char *tmp = NULL;
+size_t i;
+int ret = -1;
+
+if (!(vcpus = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)) ||
+!(online = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)) ||
+!(offlinable = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID)))
+goto cleanup;
+
+for (i = 0; i < ninfo; i++) {
+if (virBitmapSetBit(vcpus, info[i].id) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("vcpu id '%u' reported by guest agent is out of "
+ "range"), info[i].id);
+goto cleanup;
+}
+
+if (info[i].online)
+ignore_value(virBitmapSetBit(online, info[i].id));
+
+if (info[i].offlinable)
+ignore_value(virBitmapSetBit(offlinable, info[i].id));
+}
+
+#define ADD_BITMAP(name)   
\
+if (!(tmp = virBitmapFormat(name)))
\
+goto cleanup;  
\
+if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0) 
\
+goto cleanup;  
\
+VIR_FREE(tmp)
+
+ADD_BITMAP(vcpus);
+ADD_BITMAP(online);
+ADD_BITMAP(offlinable);
+
+#undef ADD_BITMAP
+
+*params = par;
+*nparams = npar;
+ret = 0;
+
+ cleanup:
+VIR_FREE(tmp);
+virBitmapFree(vcpus);
+virBitmapFree(online);
+virBitmapFree(offlinable);
+return ret;
+}
+
+
+static int
+qemuDomainGetGuestVcpus(virDomainPtr dom,
+virTypedParameterPtr *params,
+unsigned int *nparams,
+unsigned int flags)
+{
+virQEMUDriverPtr driver = dom->conn->privateData;
+virDomainObjPtr vm = NULL;
+qemuAgentCPUInfoPtr info = NULL;
+int ninfo = 0;
+int ret = -1;
+
+virCheckFlags(0, ret);
+
+if (!(vm = qemuDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainGetGuestVcpusEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+goto cleanup;
+
+if (!qemuDomainAgentAvailable(vm, true))
+goto endjob;
+
+qemuDomainObjEnterAgent(vm);
+ninfo = qemuAgentGetVCPUs(qemuDomainGetAgent(vm), &info);
+qemuDomainObjExitAgent(vm);
+
+if (ninfo < 0)
+goto endjob;
+
+if (qemuDomainGetGuestVcpusParams(params, nparams, info, ninfo) < 0)
+goto endjob;
+
+ret = 0;
+
+ endjob:
+qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+VIR_FREE(info);
+virDomainObjEndAPI(&vm);
+return ret;
+}
+
+
 static virHypervisorDriver qemuHypervisorDriver = {
 .name = QEMU_DRIVER_NAME,
 .connectOpen = qemuConnectOpen, /* 0.2.0 */
@@ -19935,6 +20048,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
 .domainSetUserPassword = qemuDomainSetUserPassword, /* 1.2.16 */
 .domainRename = qemuDomainRename, /* 1.2.19 */
 .domainMigrateStartPostCopy = qemuDomainMigrateStartPostCopy, /* 1.3.3 */
+.domainGetGuestVcpus = qemuDomainGetGuestVcpus, /* 2.0.0 */
 };


-- 
2.8.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] virsh: introduce name-uuid for list command

2016-06-20 Thread Chen Hanxiao

At 2016-06-20 21:38:42, "Peter Krempa"  wrote:
>On Mon, Jun 20, 2016 at 19:22:45 +0800, Chen Hanxiao wrote:
>> 
>> At 2016-06-15 17:36:05, "Chen Hanxiao"  wrote:
>> >From: Chen Hanxiao 
>> >
>> >This patch will show both name and UUID of domain:
>> >
>> > IdName   State  UUID
>> > ---
>> >  3 f23running
>> > 918f1dd6-b19f-412b-ba17-d113bad89af8
>> >
>> >Signed-off-by: Chen Hanxiao 
>> >---
>> 
>> ping?
>
>Jan already provided a review. I agree with his view. Allowing both
>--name --uuid is better than the new argument.

Hi,

My only concern is that why we forbid --uuid with --name at the same time at 
the begining.
If we let them come together, does that bring some backcompat issues?

Regards,
- Chen

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/7] add VirtualBox 5 C API to libvirt

2016-06-20 Thread Martin Pietsch

add VirtualBox 5 C API to libvirt
ý7zXZæÖ´F!ÏXÌë×Qð]#‰æöß(vŒã C{ôö—
D£xÔ<¨ ,}{ôBa}œ(ÈÝV’"~[FdŸ x€D‡ø¯3`Y™9ö©¹.¹n–J> 8.ÔGrá3£ð*1²ƒ×	ʒáfl›³[¤œ’¶m·
SÆ¿ÄïŒÀlúAû|mGÞÉf¾OWÁ§W«mV,“œ:7‘	ÚAà|'äàŽ—ß—)ÇLîøužT5}1sóîžñJ¾¥³ÿ¸Ï8›_ó(ÍSxЮu8@%¤»Ênl<¥k[ãÄgƒ(·cºX¡TF"Cã_,䋏ü7ê~»Rm½‚¼äáꪅA(m
-…²ÙT!…jÅZŒ‚iėÙÏEQ覓ՆE™]WöÚ*÷b2Ÿ¸	ÛÔâ
öI‹%7 ¤fy@5‘«¿×äìJÀ?†m©ÁIž¿R²¥¥Zßëÿ,ÇLøG¡C„vŽ"}…ŒTò/ªxŒ¤T\5˜ÖôýÕBÞrÙ"¤sÊŌ«†':7ˆ>{HꗮÔác_~/ž«±~°AÄbök­Gñ@R§KøüB/ÁÞÑ9sG©
])|纲š¨Šðqá3þvà•½ˆÐeÿà &ە$¯D÷„‡´×ØÇí W·r®	C•¯Â­–ÛEÂFÞ
vx«tKºó(|`ܚHb®l¶ü^²ý‡Á`~§7ŽÝcOÚÃï/Ë×ÍÔAx¤½¿þ}3XÎÎaä||Úì~ØóîHé–íĐÜë¾×/h|Ÿù1AåÔB³y«Â¦
ÑÂt¼ÐºgIMùä;/ßukÆÓ?"ê‚´Î{×\¸
·Hi­Ìé4Áž-¯ã`QLu+rY8òDû-r<6®ñÜ¼à‡’„ù°>¸^ˆ(}@¤r/Ò¬©R0äÐïx¤¦n¸ |_½ªðœ¾å(	µn„ßÚj¥«!ºŸó`æÚpúïcQ}c-XR~	ùvôîhÉ8=Â%þ
‰ñEn9þÞ·$pðIµ÷>©4–&½u2ûe˜Ä´ŸÖF¢BùBxö.ƄGWÝpnrÒÛٔJùß»¨V³1ÓUjŒA)…¯Ö6NGHLý¼­ª5íë%nj]²n·‚v.çC4êØ'Ϫ›Ô'Êñ!úFÿ¤¤L·-œvå´Qր$³tþ}•~1â p»ëm—sP¤GÞvCoùNT —s%«7ÒöСQS½éëƒïKºøò0ÕìʉøϦO…N~?³FC’å«ÉAùJRÁÑ%ü‚!CΤÙ.þ¯Ä
«FÞâE鰺¬…Ájߢ‘Ó;h	2µ‡ÄÏOŸØ3yÞô÷–z%Ö\a4ÆfCþ?ӓ/×ù>1ÚÀtÀœñvh”_-ÛE¢iÑríFü“CPJù1Ãnò²#œ –b_	Ý]¦Újx‘%
„yá#`r×É\¼ýaçW” ‹îa6Rm*^Í”Å9Ë<¸:‚<¹`êÐf0vš͊ª³Üm(`1ÔEô¤ís°FÙ°7x¼nÃàyéû±OÊûž0w™ZÝÌù…~Úï.p#Ni&Íß¹lȩ̂ùZ€æ‰@\¹LM˜Ërè?WŽ´­Ëo™þ‚QæZß	,x0õˆæ¡š?Â܏K²/瑁úõ°Œ*Èôdàn•‹yÄÙw¿>ôlJÇ$Ô ð»ôkÌ[ûӍü]Ê@ð~Š›Ì÷YšTO¸¼urʇ”#iŽÑ‰‚ç/3°|tòä2ç–GAÒlo\̈
¨ ܪԚ°Y ¢9Ù*!r›Žc”oLÖvù‘¯Úl†-Í#f÷vžS=:¾ˆ–¤pñoŠS+×w*AS™tÊfF–±°Ä•Ô¤˜ÙÊ
ïTlèŽþUÀpOrŸ|Þc(ð4áÿ…x;Seˆy¡3[XœÇUž®2	ÄźÌAV‚y´´Q>¼ôÍ9s5¼1uT摽“kN?íj&éEε?°Ž$w‚kaÜÿ+p½ŽÃjN."ܽö·$‡"]Îr§ÂX6µàÚÉÉV³yïÒhÜÝ~»IãÑÉwù…«E•úqzGT”a*ìÊ0(ÍܸrÞF‡ïPÈ¥*wú‡@}ÅÛݪu̱ù£æ¬¹Jvw_‹$å^ö’±måwë][ÑlòGþ„Ê’N‘RˆG¹û‡ð¼ÑíUÂf îӁž’Ð&³Pt‘ÍOÈwAŠ3œԍÚÄ/åw+òùg”È(3cl‹éœ}5{¼]讬q›Ö ÍJüÉՌÑ'¶é.‘½b!IZâ9²«ð9“ŸüwÐsõô˜kèPц"jJ°R^pÀ—˜q6â)’‚/µ$–2ÂLûF˜¼fŒ3
¥@ç_Kÿ»5å>¸
âgÆ¨)"/»ÀÔÇ´V÷ð‚Üà M¾¤}ÅÊ/F7«,JæÃ('¯%=5ʤö¤£;W‰ÛU¨ç<Äy§,FtG-#ÚO¨·¿»KZM“ÜNÓ½«üÊy"º¡Q¤Ÿ_öçâ^8;֋=Y¨°{Ôκ½Ê˜ªnˆ>´àúü´lââÆÔèƁŸÆÛ–”M£™µZ85xÿuLú´T¯¼ë'	3¸Ââxÿ²…¢ÏG狁±<òÜ@’‰²üìÜL…ÄE ý ÝZS¨»ð÷¦CAaËÔzôé‚ã°ÌÐp“$cˆ$ä¤öa¥C“½Ô)0ÿwhØÿȖV½èǝiPrÆ@v†ÌÿÍv<}hFp5hHï'x
í¿´8Ý!˜¢üä¦@Ä­Ýh·>ÊpšÅ෎á0î„ðU½(¿dA^¿Dlo˜G"‡b¨ÿ]á”+u©e	^¦Ð=‰ýÍƘúNïèBªõmI¼õôŸ]ìúùq°îÍôß×!„ D˜©+¬
c ì`úcS›¹2°øƒñêSÕrMÏ­
OÊm¿b*kVº73ggˆßAUunÞÃ$ùaòBãVB;–Šôò£ri¼ÿ¤2ô:¿è$yvšnæbK½µÒ]`ÍBꨯªü¢tQXz—³>ö;ßn*ìšegiÃ{X0¯–}ú¶É§a…Ú¿–ÙÉñÂä<úŽVFÿÌa«•v6]oí~o¶ÁhåA
”`v5"ÍsÔÙδť&OsôR*tRQP_»±†|Wqɱ©Ó¼„ÔëÄÊG‡ò5Åޜ)Ö€°ÆÖéËÁó²Ž_˜ÁƟEQgjʛϨp•wšz 0ÜÕË/þO~|ü
sßÎW©k
ô‚ç¸*ISc9˜ö-‹¶'.x#{ô¬JF÷F6G>!x·‘Ƕ³	[–ÝssŽTVˆà†õÄûòçW´–ø+ç,¥´Z){Ãz—$Ÿû3Á•Åι§œCTh®äÈÍ~£{£¦ hÁ:¢Ø1ª`GØû2ö%îªiaÇw—$Ép@«:«¤ÏíÅò§w´pl2…z¯Â)A4ÄaÅsãŒ`Cb-ãKÜ_ÒXÕ9…cåuÒ&0lµùyä
T6¶6u†‰FîœèMírÛ0ªçù “ó`E*†—µ›ü¢$–±¤ð^ŽQ*Ž[—På3´¦”ÎJ^eãý"{tïOQo.èKÁZY øú‹ðêFd_½UŽsO.~%ËKî¹Y1C@ø‡tw…¡ÖêýjôY,˜i_@¥áÈô4ߔ;H|ÔÝßw‰Lb æ»Ž„ª®Îâîa0J£}Ôº.»%;PËbñ8üùý®â˜xD™Šê*Èúr‘»œ¾hÌaʂ¹/w֍Jµh[”’+Ü«KáleëòPPQzëâ?ǂEéõ¦¼ÁúóY1ÿT28×öw‹³@ího0ôÔb
¾æšã±K­bQÂMǪŽ?\ו)…§ÞvNz5¯kpݖ?!H|ïð‡}#¿£}°«àl±ªþq»Ð¸v	wÖPΊéÎ3HÞñ†½UïË£Š{b[ù8R
3-§>™ìnPÍ¢“×RëLG²>UÀâ=È<ôxjCë"¿³­?ý¢5Nҍâ͞•j»2i¡ð۔íÍNŒ»*wç/”-Æyœ_óàUÝ£[øÛ<™õô=µ/{AMҎ̈M‹3·±{ˆÎ‚‡†'kÚǔՂ6qæ¨üÈ[8èŒ}vÞªý[ˆ9È@^ѨE$|È>lµ|®37ȃé4Ý•SH³žC2ªÛ´…)äìæßgèga*yсx/.	qì®nºoOoé†5ºÑʾ­kK3¡-lbÂéû<”#`6Á
YfÏzˆXÄâhMú̓î2ãßmšG‰ðÐ[>©À¨TÓñ“ËáîÊßJZ°7”å–BO®´Þ¼G
tÍ\UÕ]÷³=8ïâkۆ50¦PÊù”b×úYVr 8Þ8ïÚ©/sfÆZo
ð,"%–"Êdœñ¥ó¼¹á֎½‰2‚	ßÙôÐQ«‘üÇì¦ã‡[Ð=>+†]Ý2¸žk5~;C;8]O4¸~¶2™]<ƒŠGmWõ3vCÌ-þQÿŸµ&?s~VËUá³7¯	´Ú›MĆ÷Ë|
ÍRDúús˜c"v
ù[T…¹’
:|5ú†:"d‘¦žN,æžfùs‘ÉëÃîꆤª}íêä"ù÷^€s	âôc\mŽ;©giG¼Ç›áÒ%”EØ´œ˜>PÏ¿¯±ô†“,ˆ½Š(ò‰€€ž—˜䅾©©ü•)J˜D¹>G™9 öez´¼€ç¡+éZDMŠú׎|aéÏ¡Xhàwâ}Û¿ž™úÔu¼[ÏÓWT[ªbð¨,™Ë%€}añ57Eþõ%û|x5Ù[Ù$eƹqA-NÓ÷[Yí­Ë÷äÆ°Ä:ûwRÞejEù’ [b؄÷»ó+2F’„®Í˜ûÓTGïˆg‹VÛÀÕzéÅw÷xå¿¿ŸWõùRðç'€E̶ ©RL¬f¥36¸œ_´yëÁÖó]e!jkKÎZÑ/ªx¥X,ÌÐ-2#ñ Íªn¸ÿ¾m´Jr£ÉÂï-¥&N»Ïüí×Fò1÷Ée\4/ýýêø˜?¯FÀîýhnUël:#ád¨OȞUâ©dê )ø´]ËÒ|µ.”F‚¤å+ߗ;au·c„Ïeí¸a6'¬ZB^Ìs§t=¼ÿ
>T_êìÖ|dÀ´E÷«~%|Úé*EóJ	g}²̳Åç½LãU…g}¢ ,,ʲj^âà‰D}ð7klW#Ž‰4
½_¹‘djÛª+?|Fìû}0úRN˪"3¤½r0¦ñKõN•u<Ãê>ú	½Œ•)ÅòűÉGEýîёq=³È4	´vµw†ƒ˜_®@}èOÇ^7 
D†÷)ôgïtüóõñŸ]†&Þ論֢ôL0©	)•‰ê®¿¶pbfņ¹ÊË294½g’}oƒc0¡ˆoñ•"µ™Í)ÔØp+á†^É/ 9[
§>&4+…ö¢9àý¸EÕ±I¶#²nr#VT¿§]å@Zý7íZüeºs‚¾`ðlCxç~ôäŸÀjž!÷]VPhAOñt³šå£‹]ÔÉ­uNUâmJ’µÚ@"nŒ@±ž¼dÐOÏ·ÆGBBëLGm’IöŒó_uÊÄïNVk˜)6þÔµÿXŸA§ñb¯ç5×çeÏRí=àR–¡In<úÚ+¬â_ƒ3›‚S«q£81Ãc-g½hDÚw±û¿(èí¼Ö‰¿ï	à1¯öŽ“’×Džï”ÄQqùŸ*?°£Ï¿‘÷yÈ͗‚#2ö8½/@GÍ"•v#ò]Ÿkjâ¡K&¸
EN\œX ˜âZÈÇdîHI¼hzøc‹/ð©3»E`¬±Ë¢MéŽFÚá9841TAB¹Xuð+&êÜãX¬T•‚zR7ÑEÓî
ÝZPQcÏÒ¦îôG¤³ál(aàšc·¥¿w0鞨·÷²
q êKAìò¨‹=ùԵ튠‘¤9×,¸³ñSw3ðdNdI<«mMUãé„%û^”ã4;Ÿ“-ýv5ìý5˜©}î€U–€¼Uð­8»b­&G±öÞΉRû½ª´éÿQAÓ(ÞeIFFº.=X,@¿Š¬h™óæ¬AvÊ“

[libvirt] [PATCH 2/7] add VirtualBox 5 support to vbox_tmpl.c

2016-06-20 Thread Martin Pietsch

add VirtualBox 5 support to vbox_tmpl.c
From 96a6fbaf8bcc6b8ee4e91b23bb5b1f04f2a94a5d Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 14:28:25 +0200
Subject: [PATCH 2/7] add VirtualBox 5 support to vbox_tmpl.c

---
 src/vbox/vbox_tmpl.c | 84 
 1 file changed, 78 insertions(+), 6 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 7a8205d..ff547a1 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -69,6 +69,8 @@
 # include "vbox_CAPI_v4_3.h"
 #elif VBOX_API_VERSION == 4003004
 # include "vbox_CAPI_v4_3_4.h"
+#elif VBOX_API_VERSION == 500
+# include "vbox_CAPI_v5_0.h"
 #else
 # error "Unsupport VBOX_API_VERSION"
 #endif
@@ -1311,7 +1313,9 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
   ISnapshot *snapshot)
 {
 vboxGlobalData *data = dom->conn->privateData;
+# if VBOX_API_VERSION < 500
 IConsole *console = NULL;
+# endif /*VBOX_API_VERSION < 500*/
 IProgress *progress = NULL;
 PRUint32 state;
 nsresult rc;
@@ -1344,8 +1348,10 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
 }
 
 rc = VBOX_SESSION_OPEN(domiid.value, machine);
+# if VBOX_API_VERSION < 500
 if (NS_SUCCEEDED(rc))
 rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
+# endif /*VBOX_API_VERSION < 500*/
 if (NS_FAILED(rc)) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not open VirtualBox session with domain %s"),
@@ -1353,7 +1359,12 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
 goto cleanup;
 }
 
+# if VBOX_API_VERSION < 500
 rc = console->vtbl->RestoreSnapshot(console, snapshot, &progress);
+# elif VBOX_API_VERSION >= 500  /*VBOX_API_VERSION < 500*/
+rc = machine->vtbl->RestoreSnapshot(machine, snapshot, &progress);
+# endif /*VBOX_API_VERSION >= 500*/
+
 if (NS_FAILED(rc) || !progress) {
 if (rc == VBOX_E_INVALID_VM_STATE) {
 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -1378,7 +1389,9 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
 
  cleanup:
 VBOX_RELEASE(progress);
+# if VBOX_API_VERSION < 500
 VBOX_RELEASE(console);
+# endif /*VBOX_API_VERSION < 500*/
 VBOX_SESSION_CLOSE();
 vboxIIDUnalloc(&domiid);
 return ret;
@@ -2874,7 +2887,11 @@ _virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
 /* In vbox 2.2 and 3.0, this function will create a IHardDisk object.
  * In vbox 3.1 and later, this function will create a IMedium object.
  */
+#if VBOX_API_VERSION < 500
 return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk);
+#elif VBOX_API_VERSION >= 500 /*VBOX_API_VERSION >= 500*/
+return vboxObj->vtbl->CreateMedium(vboxObj, format, location, AccessMode_ReadWrite, DeviceType_HardDisk, hardDisk);
+#endif /*VBOX_API_VERSION >= 500*/
 }
 
 static nsresult
@@ -3366,7 +3383,23 @@ _sessionGetMachine(ISession *session, IMachine **machine)
 static nsresult
 _consoleSaveState(IConsole *console, IProgress **progress)
 {
+#if VBOX_API_VERSION < 500
 return console->vtbl->SaveState(console, progress);
+#else /*VBOX_API_VERSION < 500*/
+IMachine *machine;
+nsresult rc;
+
+rc = console->vtbl->GetMachine(console, &machine);
+
+if (NS_SUCCEEDED(rc))
+  rc = machine->vtbl->SaveState(machine, progress);
+else
+  virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to get machine from console. (error %d)"), rc);
+
+return rc;
+
+#endif /*VBOX_API_VERSION >= 500*/
 }
 
 static nsresult
@@ -3414,7 +3447,25 @@ static nsresult
 _consoleTakeSnapshot(IConsole *console, PRUnichar *name,
  PRUnichar *description, IProgress **progress)
 {
+#if VBOX_API_VERSION < 500
 return console->vtbl->TakeSnapshot(console, name, description, progress);
+#else
+IMachine *machine;
+nsresult rc;
+PRUnichar *id = NULL;
+bool bpause = true; /*NO live snapshot*/
+
+rc = console->vtbl->GetMachine(console, &machine);
+
+if (NS_SUCCEEDED(rc))
+  rc = machine->vtbl->TakeSnapshot(machine, name, description, bpause, &id, progress);
+else
+  virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unable to get machine from console. (error %d)"), rc);
+
+VBOX_RELEASE(machine);
+return rc;
+#endif /* VBOX_API_VERSION >= 500 */
 }
 
 static nsresult
@@ -3422,9 +3473,24 @@ _consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progre
 {
 #if VBOX_API_VERSION < 3001000
 return console->vtbl->DiscardSnapshot(console, IID_MEMBER(value), progress);
-#else /* VBOX_API_VERSION >= 3001000 */
+#elif VBOX_API_VERSION >= 3001000 && VBOX_API_VERSION < 500 /* VBOX_API_VERSION >= 3001000 */
 return console->vtbl->DeleteSnapshot(console, IID_MEMBER(value), progress);
-#endif /* VBOX_API_VERSION >= 3001000 */
+#else /* VBOX_AP

Re: [libvirt] [PATCH 5/6] Drop virrandomtest

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:40 +0200, Ján Tomko wrote:
> This test only checks if mocking of virRandomBytes works correctly.
> 
> Drop it to avoid infinite recursion by testing the test suite.
> ---
>  tests/Makefile.am |  5 ---
>  tests/virrandomtest.c | 86 
> ---
>  2 files changed, 91 deletions(-)
>  delete mode 100644 tests/virrandomtest.c

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/7] add VirtualBox5 support to vbox_uniformed_api.h

2016-06-20 Thread Martin Pietsch

add VirtualBox5 support to vbox_uniformed_api.h
From 81250fafc8f0a1eee05a994e6373cc9cfe19d723 Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 14:50:23 +0200
Subject: [PATCH 3/7] add VirtualBox5 support to vbox_uniformed_api.h

---
 src/vbox/vbox_uniformed_api.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index a469968..74e9ac0 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -628,5 +628,6 @@ void vbox42InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox42_20InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox43InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox43_4InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
+void vbox50InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 
 #endif /* VBOX_UNIFORMED_API_H */
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 4/7] add vbox_V5_0.c for libvirt support of VirtualBox 5

2016-06-20 Thread Martin Pietsch

add vbox_V5_0.c for libvirt support of VirtualBox 5
From 61fe1b371d8aa4adc21c329e1d6c5e112cc3af4f Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 14:56:39 +0200
Subject: [PATCH 4/7] add vbox_V5_0.c for libvirt support of VirtualBox 5

---
 src/vbox/vbox_V5_0.c | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 src/vbox/vbox_V5_0.c

diff --git a/src/vbox/vbox_V5_0.c b/src/vbox/vbox_V5_0.c
new file mode 100644
index 000..4293944
--- /dev/null
+++ b/src/vbox/vbox_V5_0.c
@@ -0,0 +1,13 @@
+/** @file vbox_V5_0.c
+ * C file to include support for multiple versions of VirtualBox
+ * at runtime.
+ */
+
+#include 
+
+/** The API Version */
+#define VBOX_API_VERSION 500
+/** Version specific prefix. */
+#define NAME(name) vbox50##name
+
+#include "vbox_tmpl.c"
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 5/7] append vbox_V5_0.c and vbox_CAPI_v5_0.h to src/Makefile.am

2016-06-20 Thread Martin Pietsch

append vbox_V5_0.c and vbox_CAPI_v5_0.h to src/Makefile.am
From 4cc0c754aeb889517f603641f2965a071d22e61d Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 15:00:05 +0200
Subject: [PATCH 5/7] append vbox_V5_0.c and vbox_CAPI_v5_0.h to
 src/Makefile.am

---
 src/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1aaa00e..f25d4dd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -790,6 +790,7 @@ VBOX_DRIVER_SOURCES =		\
 	vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h		\
 	vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h			\
 	vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h  \
+	vbox/vbox_V5_0.c vbox/vbox_CAPI_v5_0.h			\
 	vbox/vbox_common.c vbox/vbox_common.h   \
 	vbox/vbox_uniformed_api.h   \
 	vbox/vbox_get_driver.h	\
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 6/7] add VirtualBox 5 support to vbox_common.h

2016-06-20 Thread Martin Pietsch

add VirtualBox 5 support to vbox_common.h
From ddafff36a0a629fa3e9deddf7ee4533bbf320e9e Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 15:09:03 +0200
Subject: [PATCH 6/7] add VirtualBox 5 support to vbox_common.h

---
 src/vbox/vbox_common.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index fc517ac..c8787c3 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -430,6 +430,8 @@ typedef nsISupports IKeyboard;
 vbox43InstallUniformedAPI(&gVBoxAPI);   \
 } else if (uVersion >= 4003004 && uVersion < 4003051) { \
 vbox43_4InstallUniformedAPI(&gVBoxAPI); \
+} else if (uVersion >= 4003051 && uVersion < 551) { \
+vbox50InstallUniformedAPI(&gVBoxAPI);   \
 } else {\
 result = -1;\
 }   \
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 7/7] add VirtualBox 5 support to vbox_storage.c

2016-06-20 Thread Martin Pietsch

add VirtualBox 5 support to vbox_storage.c
From 7baa733a9eef6b084728e4705c3e738ae66f9f77 Mon Sep 17 00:00:00 2001
From: Martin Pietsch 
Date: Sun, 19 Jun 2016 15:19:04 +0200
Subject: [PATCH 7/7] add VirtualBox 5 support to vbox_storage.c

---
 src/vbox/vbox_storage.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 6584cd0..c849505 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -908,6 +908,8 @@ virStorageDriverPtr vboxGetStorageDriver(uint32_t uVersion)
 vbox43InstallUniformedAPI(&gVBoxAPI);
 } else if (uVersion >= 4003004 && uVersion < 4003051) {
 vbox43_4InstallUniformedAPI(&gVBoxAPI);
+} else if (uVersion >= 4003051 && uVersion < 551) {
+vbox50InstallUniformedAPI(&gVBoxAPI);
 } else {
 return NULL;
 }
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 4/6] Remove virsh-synopsis

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:39 +0200, Ján Tomko wrote:
> This tests checks that the first word after SYNOPSIS
> in virsh help ${command} output is ${command}.
> 
> This was only good to check that the command option structures
> are valid, which is now served by 'virsh self-test'.
> ---
>  tests/Makefile.am|  1 -
>  tests/virsh-synopsis | 44 
>  2 files changed, 45 deletions(-)
>  delete mode 100755 tests/virsh-synopsis

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 3/6] Introduce virsh self-test

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:38 +0200, Ján Tomko wrote:
> A new hidden command for virsh that will iterate over
> all command groups and commands and print help for every single one.
> 
> This involves running vshCmddefOptParse so we can get an error if
> one of the command's option structure is invalid.
> ---
>  .gitignore|  1 +
>  tests/Makefile.am |  1 +
>  tests/virsh-self-test | 37 +
>  tools/virsh.c | 50 ++
>  4 files changed, 89 insertions(+)
>  create mode 100755 tests/virsh-self-test
> 
> diff --git a/tests/virsh-self-test b/tests/virsh-self-test
> new file mode 100755
> index 000..42e8605
> --- /dev/null
> +++ b/tests/virsh-self-test
> @@ -0,0 +1,37 @@
> +#!/bin/sh
> +# run virsh self-test to make sure command option structures are valid
> +
> +# Copyright (C) 2008, 2009 Red Hat, Inc.

This year doesn't look correct

> +
> +# This program is free software: you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation, either version 2 of the License, or
> +# (at your option) any later version.
> +
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see
> +# .
> +
> +. "$(dirname $0)/test-lib.sh"
> +
> +fail=0
> +
> +test_url=test:///default
> +
> +test_intro "virsh-self-test"
> +$abs_top_builddir/tools/virsh -c $test_url self-test > /dev/null
> +status=$?
> +test_result 1 "virsh-self-test" $status
> +
> +if test "$status" = "1" ; then
> +   fail=1
> +fi
> +
> +test_final $counter $fail
> +
> +(exit $fail); exit $fail
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 2a807d9..8eb05d3 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -341,6 +341,50 @@ virshConnectionHandler(vshControl *ctl)
>  return NULL;
>  }
>  
> +/* -
> + * Command self-test
> + * - */
> +
> +static const vshCmdInfo info_selftest[] = {
> +{.name = "help",
> + .data = N_("internal command for testing virsh")
> +},
> +{.name = "desc",
> + .data = N_("This message should not be output.")

$ tools/virsh self-test --help
  NAME
self-test - internal command for testing virsh

  SYNOPSIS
self-test

  DESCRIPTION
This message should not be output.

I'd go with "DO NOT USE THIS COMMAND", or "internal use only".

> +},
> +{.name = NULL}
> +};
> +
> +/* Prints help for every command.
> + * That runs vshCmddefOptParse which validates
> + * the per-command options structure. */
> +static bool
> +cmdSelfTest(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
> +{
> +const vshCmdGrp *grp;
> +const vshCmdDef *def;
> +/*
> +const char *blacklist [] = {
> +"self-test",
> +"connect"
> +}; */

You probably forgot to delete this.

> +
> +vshPrint(ctl, "%s", _("Grouped commands:\n\n"));

This doesn't look necessary. Perhaps you could change it to a warning
that this output shouldn't be used.

> +
> +for (grp = cmdGroups; grp->name; grp++) {
> +for (def = grp->commands; def->name; def++) {
> +if (def->flags & VSH_CMD_FLAG_ALIAS)
> +continue;

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 6/6] Mark virsh-optparse as expensive

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:41 +0200, Ján Tomko wrote:
> ---
>  tests/virsh-optparse | 2 ++
>  1 file changed, 2 insertions(+)

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/6] tests: mock gnutls_dh_params_generate2

2016-06-20 Thread Peter Krempa
On Fri, Jun 17, 2016 at 20:04:37 +0200, Ján Tomko wrote:
> This function generates some big random numbers.
> 
> Cache the result and supply it to any subsequent generate2 calls.
> ---
>  tests/virnettlscontexttest.c |  2 +-
>  tests/virnettlssessiontest.c |  2 +-
>  tests/virrandommock.c| 51 
> 
>  3 files changed, 53 insertions(+), 2 deletions(-)


> diff --git a/tests/virrandommock.c b/tests/virrandommock.c
> index 6df5e20..04703a1 100644
> --- a/tests/virrandommock.c
> +++ b/tests/virrandommock.c
> @@ -37,3 +37,54 @@ virRandomBytes(unsigned char *buf,
>  
>  return 0;
>  }
> +
> +
> +#ifdef WITH_GNUTLS
> +# include 
> +# include 
> +# include 
> +
> +static int (*realgenerate2)(gnutls_dh_params_t dparams,
> +unsigned int bits);
> +
> +static void init_syms(void)
> +{

We have a macro to help with all the stuff below. It also has better
error message. You should use it: VIR_MOCK_REAL_INIT

> +if (realgenerate2)
> +return;
> +
> +realgenerate2 = dlsym(RTLD_NEXT, "gnutls_dh_params_generate2");
> +if (realgenerate2)
> +return;
> +
> +fprintf(stderr, "Error getting symbols");
> +abort();
> +}
> +
> +static gnutls_dh_params_t params_cache;
> +unsigned int cachebits;

Perhaps this should be static too.

> +
> +int
> +gnutls_dh_params_generate2(gnutls_dh_params_t dparams,
> +   unsigned int bits)
> +{
> +int rc = 0;
> +
> +init_syms();
> +
> +if (!params_cache) {
> +if (gnutls_dh_params_init(¶ms_cache) < 0) {
> +fprintf(stderr, "Error initializing params cache");
> +abort();
> +}
> +rc = realgenerate2(params_cache, bits);
> +
> +if (rc < 0)
> +return rc;
> +cachebits = bits;
> +}
> +
> +assert(cachebits == bits);

I'd rather not use assert here. Since you already have abort available
you can use it directly.

> +
> +return gnutls_dh_params_cpy(dparams, params_cache);
> +}

ACK with fixes.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] vsh: remove namespace poisoning

2016-06-20 Thread Ján Tomko
We already have a syntax-check to prohibit direct use of these
allocation functions.
---
 tools/vsh.c |  6 --
 tools/vsh.h | 10 --
 2 files changed, 16 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 8649305..2b78919 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -71,9 +71,6 @@
 const vshCmdGrp *cmdGroups;
 const vshCmdDef *cmdSet;
 
-/* Bypass header poison */
-#undef strdup
-
 
 /* simple handler for oom conditions */
 static void
@@ -164,9 +161,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char 
*filename, int line)
 exit(EXIT_FAILURE);
 }
 
-/* Poison the raw allocating identifiers in favor of our vsh variants.  */
-#define strdup use_vshStrdup_instead_of_strdup
-
 int
 vshNameSorter(const void *a, const void *b)
 {
diff --git a/tools/vsh.h b/tools/vsh.h
index f738a6f..8d67397 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -453,16 +453,6 @@ char *_vshStrdup(vshControl *ctl, const char *s, const 
char *filename,
  int line);
 # define vshStrdup(_ctl, _s)_vshStrdup(_ctl, _s, __FILE__, __LINE__)
 
-/* Poison the raw allocating identifiers in favor of our vsh variants.  */
-# undef malloc
-# undef calloc
-# undef realloc
-# undef strdup
-# define malloc use_vshMalloc_instead_of_malloc
-# define calloc use_vshCalloc_instead_of_calloc
-# define realloc use_vshRealloc_instead_of_realloc
-# define strdup use_vshStrdup_instead_of_strdup
-
 /* Macros to help dealing with mutually exclusive options. */
 
 /* VSH_EXCLUSIVE_OPTIONS_EXPR:
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/3] Remove unused SOL_NETLINK macro

2016-06-20 Thread Ján Tomko
Introduced by commit d575679, unused at the time.
---
 src/util/virnetlink.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 5491ece..513f36e 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -42,10 +42,6 @@
 #include "virmacaddr.h"
 #include "virerror.h"
 
-#ifndef SOL_NETLINK
-# define SOL_NETLINK 270
-#endif
-
 #define VIR_FROM_THIS VIR_FROM_NET
 
 VIR_LOG_INIT("util.netlink");
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/3] Remove unused macros

2016-06-20 Thread Ján Tomko
Ján Tomko (3):
  Remove unused SOL_NETLINK macro
  vbox: remove duplicate macros
  vsh: remove namespace poisoning

 src/util/virnetlink.c   |  4 
 src/vbox/vbox_driver.c  |  2 --
 src/vbox/vbox_network.c | 43 ---
 tools/vsh.c |  6 --
 tools/vsh.h | 10 --
 5 files changed, 65 deletions(-)

-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 2/3] vbox: remove duplicate macros

2016-06-20 Thread Ján Tomko
There is a definiton of VIR_FROM_THIS just two lines above.

The rest is defined in vbox_common.h.
---
 src/vbox/vbox_driver.c  |  2 --
 src/vbox/vbox_network.c | 43 ---
 2 files changed, 45 deletions(-)

diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index a5f3721..b3b4ee6 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -48,8 +48,6 @@
 
 VIR_LOG_INIT("vbox.vbox_driver");
 
-#define VIR_FROM_THIS VIR_FROM_VBOX
-
 #if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER)
 static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
  virConnectAuthPtr auth 
ATTRIBUTE_UNUSED,
diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c
index ee409e3..4cfc365 100644
--- a/src/vbox/vbox_network.c
+++ b/src/vbox/vbox_network.c
@@ -37,49 +37,6 @@
 
 VIR_LOG_INIT("vbox.vbox_network");
 
-#define RC_SUCCEEDED(rc) NS_SUCCEEDED(rc.resultCode)
-#define RC_FAILED(rc) NS_FAILED(rc.resultCode)
-
-#define VBOX_UTF16_FREE(arg)\
-do {\
-if (arg) {  \
-gVBoxAPI.UPFN.Utf16Free(data->pFuncs, arg); \
-(arg) = NULL;   \
-}   \
-} while (0)
-
-#define VBOX_UTF8_FREE(arg) \
-do {\
-if (arg) {  \
-gVBoxAPI.UPFN.Utf8Free(data->pFuncs, arg);  \
-(arg) = NULL;   \
-}   \
-} while (0)
-
-#define VBOX_UTF16_TO_UTF8(arg1, arg2)  
gVBoxAPI.UPFN.Utf16ToUtf8(data->pFuncs, arg1, arg2)
-#define VBOX_UTF8_TO_UTF16(arg1, arg2)  
gVBoxAPI.UPFN.Utf8ToUtf16(data->pFuncs, arg1, arg2)
-
-#define VBOX_RELEASE(arg) \
-do {  \
-if (arg) {\
-gVBoxAPI.nsUISupports.Release((void *)arg);   \
-(arg) = NULL; \
-} \
-} while (0)
-
-#define vboxIIDUnalloc(iid) 
gVBoxAPI.UIID.vboxIIDUnalloc(data, iid)
-#define vboxIIDToUUID(iid, uuid)
gVBoxAPI.UIID.vboxIIDToUUID(data, iid, uuid)
-#define vboxIIDFromUUID(iid, uuid)  
gVBoxAPI.UIID.vboxIIDFromUUID(data, iid, uuid)
-#define vboxIIDIsEqual(iid1, iid2)  
gVBoxAPI.UIID.vboxIIDIsEqual(data, iid1, iid2)
-#define DEBUGIID(msg, iid)  gVBoxAPI.UIID.DEBUGIID(msg, 
iid)
-#define vboxIIDFromArrayItem(iid, array, idx) \
-gVBoxAPI.UIID.vboxIIDFromArrayItem(data, iid, array, idx)
-
-#define VBOX_IID_INITIALIZE(iid)
gVBoxAPI.UIID.vboxIIDInitialize(iid)
-
-#define ARRAY_GET_MACHINES \
-(gVBoxAPI.UArray.handleGetMachines(data->vboxObj))
-
 static vboxUniformedAPI gVBoxAPI;
 
 /**
-- 
2.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v3 4/4] util: Make failure to get supplementary group list for a uid non-fatal

2016-06-20 Thread Peter Krempa
On Mon, Jun 20, 2016 at 08:10:10 -0400, John Ferlan wrote:
> 
> 
> On 06/17/2016 09:44 AM, Peter Krempa wrote:
> > Since introduction of the DAC security driver we've documented that
> > seclabels with a leading + can be used with numerical uid. This would
> > not work though with the rest of libvirt if the uid was not actually
> > used in the system as we'd fail when trying to get a list of
> > supplementary groups for the given uid. Since a uid without entry in
> > /etc/passwd (or other user database) will not have any supplementary
> > groups we can treat the failure to obtain them as such.
> > 
> > This patch modifies virGetGroupList to not report the error for missing
> > users and makes it return an empty list or just the group specified in
> > @gid.
> > 
> > All callers will grand less permissions in case of failure and thus this
> > change is safe.
> 
> "grand less"?  did you mean "gain less"?

I've explained it a bit more:

All callers will grant less permissions to a user in case of failure of
this function and thus this change is safe.

> ACK series (just typed out loud below)
> 
> John
> > ---
> >  src/util/virutil.c | 31 ---
> >  1 file changed, 16 insertions(+), 15 deletions(-)
> > 
> > diff --git a/src/util/virutil.c b/src/util/virutil.c
> > index 392091b..60da17b 100644
> > --- a/src/util/virutil.c
> > +++ b/src/util/virutil.c

[...]

> > +}
> >  }
> 
> Playing the "what if" game here.  If for some reason uid == -1 OR
> virGetUserEnt fails, then
> 
> gid - still to be determined
> ret = 0
> 
> > 
> >  if (gid != (gid_t)-1) {
> > 
> 
> If we enter this "if", then the for loop will exit immediately and the
> VIR_APPEND_ELEMENT will append that gid onto *list which is IIRC what we
> want. Then ret will be set to 1 (i) and we return. Otherwise if gid ==
> -1, then we return 0, which is still fine.

Yep I wanted to achieve exactly this logic as it makes most sense IMO.

I've pushed this now. Thanks.

Peter

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] storage: Fix several issues with transient pool cleanup

2016-06-20 Thread Jovanka Gulicoska
There are several cases where we do not handle transient pool destroy
and cleanup correctly. For example:

https://bugzilla.redhat.com/show_bug.cgi?id=1227475

Move the pool cleanup logic to a new function storagePoolSetInactive and
use it consistently.
---
 src/storage/storage_driver.c | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index e2d729f..74af35d 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -77,6 +77,21 @@ static void storageDriverUnlock(void)
 }
 
 static void
+storagePoolSetInactive(virStoragePoolObjPtr pool)
+{
+pool->active = false;
+
+if (pool->configFile == NULL) {
+virStoragePoolObjRemove(&driver->pools, pool);
+pool = NULL;
+} else if (pool->newDef) {
+virStoragePoolDefFree(pool->def);
+pool->def = pool->newDef;
+pool->newDef = NULL;
+}
+}
+
+static void
 storagePoolUpdateState(virStoragePoolObjPtr pool)
 {
 bool active;
@@ -143,6 +158,7 @@ storagePoolUpdateAllState(void)
 virStoragePoolObjPtr pool = driver->pools.objs[i];
 
 virStoragePoolObjLock(pool);
+storagePoolSetInactive(pool);
 storagePoolUpdateState(pool);
 virStoragePoolObjUnlock(pool);
 }
@@ -198,6 +214,7 @@ storageDriverAutostart(void)
 unlink(stateFile);
 if (backend->stopPool)
 backend->stopPool(conn, pool);
+storagePoolSetInactive(pool);
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to autostart storage pool '%s': %s"),
pool->def->name, virGetLastErrorMessage());
@@ -737,7 +754,7 @@ storagePoolCreateXML(virConnectPtr conn,
 unlink(stateFile);
 if (backend->stopPool)
 backend->stopPool(conn, pool);
-virStoragePoolObjRemove(&driver->pools, pool);
+storagePoolSetInactive(pool);
 pool = NULL;
 goto cleanup;
 }
@@ -1068,16 +1085,7 @@ storagePoolDestroy(virStoragePoolPtr obj)
 VIR_STORAGE_POOL_EVENT_STOPPED,
 0);
 
-pool->active = false;
-
-if (pool->configFile == NULL) {
-virStoragePoolObjRemove(&driver->pools, pool);
-pool = NULL;
-} else if (pool->newDef) {
-virStoragePoolDefFree(pool->def);
-pool->def = pool->newDef;
-pool->newDef = NULL;
-}
+storagePoolSetInactive(pool);
 
 ret = 0;
 
@@ -1197,13 +1205,7 @@ storagePoolRefresh(virStoragePoolPtr obj,
 pool->def->uuid,
 VIR_STORAGE_POOL_EVENT_STOPPED,
 0);
-pool->active = false;
-
-if (pool->configFile == NULL) {
-virStoragePoolObjRemove(&driver->pools, pool);
-pool = NULL;
-}
-goto cleanup;
+storagePoolSetInactive(pool);
 }
 
 event = virStoragePoolEventLifecycleNew(pool->def->name,
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/3] Remove unused SOL_NETLINK macro

2016-06-20 Thread Laine Stump

On 06/20/2016 11:28 AM, Ján Tomko wrote:

Introduced by commit d575679, unused at the time.
---
  src/util/virnetlink.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 5491ece..513f36e 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -42,10 +42,6 @@
  #include "virmacaddr.h"
  #include "virerror.h"
  
-#ifndef SOL_NETLINK

-# define SOL_NETLINK 270
-#endif
-
  #define VIR_FROM_THIS VIR_FROM_NET
  
  VIR_LOG_INIT("util.netlink");


Provisional ACK since you are correct that it isn't visibly used, but I 
can't help thinking the author had some reason for adding it. It looks 
like SOL_NETLINK wasn't present in kernel 2.6 (RHEL6 vintage - although 
it is mentioned in a comment of one of the system #includes), but was 
there by the time of kernel 3.10 (RHEL7).


I Cc'ed the author's email on this reply. If we don't hear back from 
him, I guess we can assume it was something put in to test an alternate 
netlink protocol, and we can add it back in later if it causes a build 
problem on some platform, or is needed for something in the future.  (I 
did try a stock build on RHEL6 with this chunk removed, and it had no 
problems; that, combined with the fact that it's defined below all the 
#includes in the file shows that it's not a case of a reference hidden 
in an include file somewhere).


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] virsh: introduce name-uuid for list command

2016-06-20 Thread John Ferlan


On 06/20/2016 10:51 AM, Chen Hanxiao wrote:
> 
> At 2016-06-20 21:38:42, "Peter Krempa"  wrote:
>> On Mon, Jun 20, 2016 at 19:22:45 +0800, Chen Hanxiao wrote:
>>>
>>> At 2016-06-15 17:36:05, "Chen Hanxiao"  wrote:
 From: Chen Hanxiao 

 This patch will show both name and UUID of domain:

 IdName   State  UUID
 ---
  3 f23running
 918f1dd6-b19f-412b-ba17-d113bad89af8

 Signed-off-by: Chen Hanxiao 
 ---
>>>
>>> ping?
>>
>> Jan already provided a review. I agree with his view. Allowing both
>> --name --uuid is better than the new argument.
> 
> Hi,
> 
> My only concern is that why we forbid --uuid with --name at the same time at 
> the begining.
> If we let them come together, does that bring some backcompat issues?
> 

you can research the history rather easily using gitk... I suggest
looking at commit id '419e5fb3' which implemented the --uuid and --name
switches and the commit message gives you more details.

In addition to what's already been posted - you're adding UUID but
making it an exclusive of optTitle, but I see no check for that. What if
someone wanted both?

Another way to "think" about this is that "by default" there are 3 items
displayed. Historically, if someone uses --uuid, then only uuid's are
displayed. Likewise, if someone uses --name, then only name's are
displayed.  Over time, we allowed --title to mean default (or optTable
in the code) plus title.

So now you're proposing to allow displaying the UUID. Since it's not a
"default" output, you can choose where/how to place it. Of course your
proposal can bring out various opinions - my would probably keep Name
and UUID closer together.  UUID is at least "sized" so that helps with
columnar output.

Perhaps using the VSH_EXCLUSIVE* macros may help you devise a way to
print out perhaps what someone wants. I don't think it would be
difficult to allow the default, but then allow someone to supply other
column names as switches to allow an "ordered" display of data (eg,
virsh --id --name, displays id and name.  virsh --name --uuid --state
displays name, uuid, and state).

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/3] vbox: remove duplicate macros

2016-06-20 Thread Laine Stump

On 06/20/2016 11:28 AM, Ján Tomko wrote:

There is a definiton of VIR_FROM_THIS just two lines above.

The rest is defined in vbox_common.h.
---
  src/vbox/vbox_driver.c  |  2 --
  src/vbox/vbox_network.c | 43 ---
  2 files changed, 45 deletions(-)


ACK.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 3/3] vsh: remove namespace poisoning

2016-06-20 Thread Laine Stump

On 06/20/2016 11:28 AM, Ján Tomko wrote:

We already have a syntax-check to prohibit direct use of these
allocation functions.


Yep. This was added in commit d9adac in 2010, well before we had such 
syntax rules, but it's pointless now.


ACK.


---
  tools/vsh.c |  6 --
  tools/vsh.h | 10 --
  2 files changed, 16 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 8649305..2b78919 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -71,9 +71,6 @@
  const vshCmdGrp *cmdGroups;
  const vshCmdDef *cmdSet;
  
-/* Bypass header poison */

-#undef strdup
-
  
  /* simple handler for oom conditions */

  static void
@@ -164,9 +161,6 @@ _vshStrdup(vshControl *ctl, const char *s, const char 
*filename, int line)
  exit(EXIT_FAILURE);
  }
  
-/* Poison the raw allocating identifiers in favor of our vsh variants.  */

-#define strdup use_vshStrdup_instead_of_strdup
-
  int
  vshNameSorter(const void *a, const void *b)
  {
diff --git a/tools/vsh.h b/tools/vsh.h
index f738a6f..8d67397 100644
--- a/tools/vsh.h
+++ b/tools/vsh.h
@@ -453,16 +453,6 @@ char *_vshStrdup(vshControl *ctl, const char *s, const 
char *filename,
   int line);
  # define vshStrdup(_ctl, _s)_vshStrdup(_ctl, _s, __FILE__, __LINE__)
  
-/* Poison the raw allocating identifiers in favor of our vsh variants.  */

-# undef malloc
-# undef calloc
-# undef realloc
-# undef strdup
-# define malloc use_vshMalloc_instead_of_malloc
-# define calloc use_vshCalloc_instead_of_calloc
-# define realloc use_vshRealloc_instead_of_realloc
-# define strdup use_vshStrdup_instead_of_strdup
-
  /* Macros to help dealing with mutually exclusive options. */
  
  /* VSH_EXCLUSIVE_OPTIONS_EXPR:



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] storage: Fix several issues with transient pool cleanup

2016-06-20 Thread Cole Robinson
On 06/20/2016 12:18 PM, Jovanka Gulicoska wrote:
> There are several cases where we do not handle transient pool destroy
> and cleanup correctly. For example:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1227475
> 
> Move the pool cleanup logic to a new function storagePoolSetInactive and
> use it consistently.
> ---
>  src/storage/storage_driver.c | 38 --
>  1 file changed, 20 insertions(+), 18 deletions(-)
> 
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index e2d729f..74af35d 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -77,6 +77,21 @@ static void storageDriverUnlock(void)
>  }
>  
>  static void
> +storagePoolSetInactive(virStoragePoolObjPtr pool)
> +{
> +pool->active = false;
> +
> +if (pool->configFile == NULL) {
> +virStoragePoolObjRemove(&driver->pools, pool);
> +pool = NULL;
> +} else if (pool->newDef) {
> +virStoragePoolDefFree(pool->def);
> +pool->def = pool->newDef;
> +pool->newDef = NULL;
> +}
> +}
> +

Hmm. I'm testing this, and I see one problem here. The pool = NULL bit is not
propagated to the caller in any way, which is required to not crash in cleanup
paths if the pool disappears.

I think this function needs to take virStoragePoolObjPtr *pool, and callers
pass in &pool, so the *pool = NULL; bit affects the caller.

> +static void
>  storagePoolUpdateState(virStoragePoolObjPtr pool)
>  {
>  bool active;
> @@ -143,6 +158,7 @@ storagePoolUpdateAllState(void)
>  virStoragePoolObjPtr pool = driver->pools.objs[i];
>  
>  virStoragePoolObjLock(pool);
> +storagePoolSetInactive(pool);
>  storagePoolUpdateState(pool);
>  virStoragePoolObjUnlock(pool);

I see this bit here is required to fix the reported bug, but I think it should
be pushed into storagePoolUpdateState(pool), since there are cases there where
the pool may be marked as 'inactive' as well. This is the diff I came up with:

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 74af35d..ae965ee 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -130,16 +130,19 @@ storagePoolUpdateState(virStoragePoolObjPtr pool)
 if (backend->refreshPool(NULL, pool) < 0) {
 if (backend->stopPool)
 backend->stopPool(NULL, pool);
+active = false;
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restart storage pool '%s': %s"),
pool->def->name, virGetLastErrorMessage());
 goto error;
 }
+pool->active = true;
 }

-pool->active = active;
 ret = 0;
  error:
+if (!active)
+storagePoolSetInactive(pool);
 if (ret < 0) {
 if (stateFile)
 unlink(stateFile);
@@ -158,7 +161,6 @@ storagePoolUpdateAllState(void)
 virStoragePoolObjPtr pool = driver->pools.objs[i];

 virStoragePoolObjLock(pool);
-storagePoolSetInactive(pool);
 storagePoolUpdateState(pool);
 virStoragePoolObjUnlock(pool);
 }


>  }
> @@ -198,6 +214,7 @@ storageDriverAutostart(void)
>  unlink(stateFile);
>  if (backend->stopPool)
>  backend->stopPool(conn, pool);
> +storagePoolSetInactive(pool);
>  virReportError(VIR_ERR_INTERNAL_ERROR,
> _("Failed to autostart storage pool '%s': 
> %s"),
> pool->def->name, virGetLastErrorMessage());
> @@ -737,7 +754,7 @@ storagePoolCreateXML(virConnectPtr conn,
>  unlink(stateFile);
>  if (backend->stopPool)
>  backend->stopPool(conn, pool);
> -virStoragePoolObjRemove(&driver->pools, pool);
> +storagePoolSetInactive(pool);
>  pool = NULL;

This pool = NULL; line can be dropped if the above first suggestion is
implemented.

Otherwise this looks correct to me

Thanks,
Cole

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH RFC] libxl: set serial source path for console type=serial

2016-06-20 Thread Joao Martins
Guests use a  (and sometimes  pair) to represent
the console. On the callback that is called when console is brought up
(NB: before domain starts), we fill the path of the console element with
the appropriate "/dev/pts/X". For PV guests it all works fine, although
for HVM guests it doesn't. Consequently we end up seeing erronous
behaviour on HVM guests where console path is not displayed on the XML
but still can be accessed with virDomainOpenConsole after booting guest.
Consumers of this XML (e.g. Openstack) also won't be able to use the
console path. Finally, the path set in consoles array won't persist
across daemon reboots, thus rendering admins/users with no access to
console with a message such as:

"error: operation failed: PTY device is not yet assigned"

This is because: for HVM guests, DefFormatInternal will ignore the
console element and instead write it with the content of the serial
element for target type = serial which isn't touched in our
libxlConsoleCallback. To address that we introduce a new helper routine
libxlConsoleSetSourcePath() that sets the source path and thus also
handling this case. That is by setting the source path on with serial
element akin to the one indexed by console "port". This way we keep
similar behaviour for PV and HVM guests.

Signed-off-by: Joao Martins 
---
 src/libxl/libxl_domain.c | 35 +++
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 221af87..4a46143 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -955,6 +955,35 @@ libxlNetworkPrepareDevices(virDomainDefPtr def)
 return 0;
 }
 
+static int
+libxlConsoleSetSourcePath(virDomainDefPtr def, virDomainChrDefPtr console,
+  char *path)
+{
+int ret = -1;
+size_t i;
+
+if (!path || path[0] == '\0')
+return ret;
+
+if (VIR_STRDUP(console->source.data.file.path, path) < 0)
+return ret;
+
+if (console->targetType != VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)
+return 0;
+
+for (i = 0; i < def->nserials; i++) {
+virDomainChrDefPtr serial = def->serials[i];
+
+if (serial->target.port == console->target.port &&
+VIR_STRDUP(serial->source.data.file.path, path) >= 0) {
+ret = 0;
+break;
+}
+}
+
+return ret;
+}
+
 static void
 libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback)
 {
@@ -977,10 +1006,8 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, 
void *for_callback)
 &console);
 if (!ret) {
 VIR_FREE(chr->source.data.file.path);
-if (console && console[0] != '\0') {
-ignore_value(VIR_STRDUP(chr->source.data.file.path,
-console));
-}
+if (libxlConsoleSetSourcePath(vm->def, chr, console) < 0)
+VIR_WARN("Failed to set console source path");
 }
 VIR_FREE(console);
 }
-- 
2.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] conf: limit chassisNr, and busNr to a minimum value of 1, not 0

2016-06-20 Thread Laine Stump
In the case of chassisNr (used to set chassis_nr of a pci-bridge
controller), 0 is reserved for / used by the pci[e]-root bus. In the
base of busNr, a value of 0 would mean that the root bus had no places
available to plug in new buses, including the pxb itself (the
documentation I wrote for pxb even noted the limit of busNr as 1.254).

NB: oddly, the "chassis" attribute, which is used for pcie-root-port
and pcie-switch-downstream-port *can* be set to 0, since it's the
combination of {chassis, slot} that needs to be unique, not chassis by
itself (and slot 0 of pcie-root is reserved, while pcie-*-port can use
*only* slot 0).

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1342962
---
 docs/formatdomain.html.in | 2 +-
 src/conf/domain_conf.c| 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d181ffa..88db3bc 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3277,7 +3277,7 @@
 control QEMU's "chassis_nr" option for the pci-bridge device
 (normally libvirt automatically sets this to the same value as
 the index attribute of the pci controller). If set, chassisNr
-must be between 0 and 255.
+must be between 1 and 255.
   
   chassis
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 23ca236..9a6610b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8426,11 +8426,11 @@ virDomainControllerDefParseXML(xmlNodePtr node,
chassisNr);
 goto error;
 }
-if (def->opts.pciopts.chassisNr < 0 ||
+if (def->opts.pciopts.chassisNr < 1 ||
 def->opts.pciopts.chassisNr > 255) {
 virReportError(VIR_ERR_XML_ERROR,
_("PCI controller chassisNr '%s' out of range "
- "- must be 0-255"),
+ "- must be 1-255"),
chassisNr);
 goto error;
 }
@@ -8477,11 +8477,11 @@ virDomainControllerDefParseXML(xmlNodePtr node,
busNr);
 goto error;
 }
-if (def->opts.pciopts.busNr < 0 ||
+if (def->opts.pciopts.busNr < 1 ||
 def->opts.pciopts.busNr > 254) {
 virReportError(VIR_ERR_XML_ERROR,
_("PCI controller busNr '%s' out of range "
- "- must be 0-254"),
+ "- must be 1-254"),
busNr);
 goto error;
 }
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [Qemu-devel] [PATCH v2 0/6] Add runnability info to query-cpu-definitions

2016-06-20 Thread Eduardo Habkost

Ping? No other feedback on this?

On Mon, Jun 06, 2016 at 05:05:37PM -0300, Eduardo Habkost wrote:
> This series extends query-cpu-definitions to include an extra
> field: "unavailable-features". The new field can be used to find
> out reasons that prevent the CPU model from running in the
> current host.
> 
> This will return information based on the current machine and
> accelerator only. In the future we may extend these mechanisms to
> allow querying other machines and other accelerators without
> restarting QEMU, but it will require some reorganization of
> QEMU's main code.
> 
> This series is based on my 'x86-next' branch, at:
>   git://github.com/ehabkost/qemu.git x86-next
> 
> Changes v1 -> v2:
> * Fixed documentation to say "(since 2.7)"
> * Removed @runnable field, improved documentation
> 
> Example command output:
> 
>   { "return": [
>   {
> "unavailable-features": [ "kvm" ],
>  "name": "host"
>   },
>   {
> "unavailable-features": [],
> "name": "qemu64"
>   },
>   {
> "unavailable-features": [],
> "name": "qemu32"
>   },
>   {
> "unavailable-features": ["npt", "fxsr-opt", "vme"],
> "name": "phenom"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "pentium3"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "pentium2"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "pentium"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "n270"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "kvm64"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "kvm32"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "coreduo"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "core2duo"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "athlon"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Westmere"
>   },
>   {
> "unavailable-features": ["xsavec", "3dnowprefetch", "rdseed", "rtm", 
> "invpcid", "erms", "avx2", "hle", "rdrand", "f16c", "avx", "tsc-deadline", 
> "x2apic", "pcid", "fma", "vme"],
> "name": "Skylake-Client"
>   },
>   {
> "unavailable-features": ["avx", "tsc-deadline", "x2apic", "vme"],
> "name": "SandyBridge"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Penryn"
>   },
>   {
> "unavailable-features": ["tbm", "fma4", "xop", "3dnowprefetch", 
> "misalignsse", "f16c", "avx", "fma", "vme"],
> "name": "Opteron_G5"
>   },
>   {
> "unavailable-features": ["fma4", "xop", "3dnowprefetch", 
> "misalignsse", "avx", "vme"],
> "name": "Opteron_G4"
>   },
>   {
> "unavailable-features": ["misalignsse", "vme"],
> "name": "Opteron_G3"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Opteron_G2"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Opteron_G1"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Nehalem"
>   },
>   {
> "unavailable-features": ["erms", "rdrand", "f16c", "avx", 
> "tsc-deadline", "x2apic", "vme"],
> "name": "IvyBridge"
>   },
>   {
> "unavailable-features": ["rtm", "invpcid", "erms", "avx2", "hle", 
> "rdrand", "f16c", "avx", "tsc-deadline", "x2apic", "pcid", "fma", "vme"],
> "name": "Haswell"
>   },
>   {
> "unavailable-features": ["invpcid", "erms", "avx2", "rdrand", "f16c", 
> "avx", "tsc-deadline", "x2apic", "pcid", "fma", "vme"],
> "name": "Haswell-noTSX"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "Conroe"
>   },
>   {
> "unavailable-features": ["3dnowprefetch", "rdseed", "rtm", "invpcid", 
> "erms", "avx2", "hle", "rdrand", "f16c", "avx", "tsc-deadline", "x2apic", 
> "pcid", "fma", "vme"],
> "name": "Broadwell"
>   },
>   {
> "unavailable-features": ["3dnowprefetch", "rdseed", "invpcid", 
> "erms", "avx2", "rdrand", "f16c", "avx", "tsc-deadline", "x2apic", "pcid", 
> "fma", "vme"],
> "name": "Broadwell-noTSX"
>   },
>   {
> "unavailable-features": ["vme"],
> "name": "486"
>   }
>   ]}
> 
> Cc: David Hildenbrand 
> Cc: Michael Mueller 
> Cc: Christian Borntraeger 
> Cc: Cornelia Huck 
> Cc: Jiri Denemark 
> Cc: libvir-list@redhat.com
> 
> Eduardo Habkost (6):
>   target-i386: List CPU models using subclass list
>   target-i386: Move warning code outside x86_cpu_filter_features()
>   target-i386: Define CPUID filtering functions before x86_cpu_list()
>   qmp: Add runnability information to query-cpu-definitions
>   target-i386: Use "-" instea

[libvirt] [PATCH 2/3] target-i386: Introduce x86_cpu_load_host_data() function

2016-06-20 Thread Eduardo Habkost
The code that loads host-specific information inside
x86_cpu_realizefn() will be reused by the implementation of
query-host-cpu, so move it to a separate function.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index aadd0b9..3d3635d 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1491,6 +1491,20 @@ void x86_cpu_change_kvm_default(const char *prop, const 
char *value)
 static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
bool migratable_only);
 
+/* Load host-dependent CPU information, when applicable */
+static void x86_cpu_load_host_data(X86CPU *cpu)
+{
+CPUX86State *env = &cpu->env;
+FeatureWord w;
+
+if (cpu->host_features) {
+for (w = 0; w < FEATURE_WORDS; w++) {
+env->features[w] =
+x86_cpu_get_supported_feature_word(w, cpu->migratable);
+}
+}
+}
+
 #ifdef CONFIG_KVM
 
 static int cpu_x86_fill_model_id(char *str)
@@ -3012,18 +3026,13 @@ static void x86_cpu_realizefn(DeviceState *dev, Error 
**errp)
 return;
 }
 
+x86_cpu_load_host_data(cpu);
+
 /*TODO: cpu->host_features incorrectly overwrites features
  * set using "feat=on|off". Once we fix this, we can convert
  * plus_features & minus_features to global properties
  * inside x86_cpu_parse_featurestr() too.
  */
-if (cpu->host_features) {
-for (w = 0; w < FEATURE_WORDS; w++) {
-env->features[w] =
-x86_cpu_get_supported_feature_word(w, cpu->migratable);
-}
-}
-
 for (w = 0; w < FEATURE_WORDS; w++) {
 cpu->env.features[w] |= plus_features[w];
 cpu->env.features[w] &= ~minus_features[w];
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] target-i386: Implement arch_query_host_cpu_info()

2016-06-20 Thread Eduardo Habkost
Return information on the host CPU using the "host" CPU model.

Signed-off-by: Eduardo Habkost 
---
 target-i386/cpu.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 3d3635d..06b0b99 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -30,6 +30,7 @@
 #include "qemu/config-file.h"
 #include "qapi/qmp/qerror.h"
 
+#include "qom/qom-qobject.h"
 #include "qapi-types.h"
 #include "qapi-visit.h"
 #include "qapi/visitor.h"
@@ -,6 +2223,69 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error 
**errp)
 return cpu_list;
 }
 
+/* Return host CPU info by instantiating a "host" CPU object,
+ * and returning all the default values for QOM properties
+ */
+void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp)
+{
+Object *obj = NULL;
+ObjectPropertyIterator iter;
+ObjectProperty *prop;
+QDict *propdict = NULL;
+Error *err = NULL;
+
+/* Host CPU information is returned only in KVM mode, by now */
+if (!kvm_enabled()) {
+goto out;
+}
+
+obj = object_new(X86_CPU_TYPE_NAME("host"));
+
+object_property_set_bool(obj, migratable, "migratable", &err);
+if (err) {
+goto out;
+}
+
+x86_cpu_load_host_data(X86_CPU(obj));
+
+propdict = qdict_new();
+
+object_property_iter_init(&iter, obj);
+while ((prop = object_property_iter_next(&iter))) {
+QObject *v;
+
+/* Skip properties that aren't useful for the query because
+ * they don't make sense here:
+ * - "realized" doesn't make sense because we never realize
+ *   the CPU object above.
+ * - "filtered-features" doesn't make sense because we
+ *   never filter the feature list (as it is done inside
+ *   realizefn).
+ */
+if (!strcmp(prop->name, "realized") ||
+!strcmp(prop->name, "filtered-features")) {
+continue;
+}
+
+v = object_property_get_qobject(obj, prop->name, &err);
+if (err) {
+goto out;
+}
+qdict_put_obj(propdict, prop->name, v);
+}
+
+r->has_qom_properties = true;
+r->qom_properties = QOBJECT(propdict);
+
+out:
+object_unref(obj);
+if (err) {
+qobject_decref(QOBJECT(propdict));
+error_propagate(errp, err);
+}
+return;
+}
+
 static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w,
bool migratable_only)
 {
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/3] qmp: Add query-host-cpu command

2016-06-20 Thread Eduardo Habkost
The command can be used to return host-specific CPU capabilities
information.

Signed-off-by: Eduardo Habkost 
---
 include/sysemu/arch_init.h   |  1 +
 qapi-schema.json | 36 
 qmp-commands.hx  |  6 ++
 qmp.c| 13 +
 stubs/Makefile.objs  |  1 +
 stubs/arch-query-host-cpu-info.c |  8 
 6 files changed, 65 insertions(+)
 create mode 100644 stubs/arch-query-host-cpu-info.c

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index d690dfa..54215ab 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -35,5 +35,6 @@ int kvm_available(void);
 int xen_available(void);
 
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp);
+void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp);
 
 #endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 19e3ef2..d2f4879 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3047,6 +3047,42 @@
 ##
 { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'] }
 
+
+##
+# @HostCPUInfo:
+#
+# Information on CPU capabilities supported by the current host.
+#
+# @qom-properties: #optional Values of CPU QOM properties corresponding
+#  to CPU capabilities supported by the host.
+#
+# Most properties returned in qom-properties are boolean properties
+# indicating if a feature can be enabled in the current host. Other
+# non-boolean properties may be returned, the semantics of each property
+# depend on the architecture-specific code that handle them.
+#
+# Since: 2.7.0
+##
+{ 'struct': 'HostCPUInfo',
+  'data': { '*qom-properties': 'any' } }
+
+##
+# @query-host-cpu:
+#
+# @migratable: #optional If false, unmigratable features will be
+#  returned as well. If true, only migratable features
+#  will be returned. Defaults to true.
+#
+# Return information about CPU capabilities in the current host.
+# The returned data may depend on machine and accelerator configuration.
+#
+# Returns: A HostCPUInfo object.
+#
+# Since: 2.7.0
+##
+{ 'command': 'query-host-cpu', 'data': { '*migratable': 'bool' },
+  'returns': 'HostCPUInfo' }
+
 # @AddfdInfo:
 #
 # Information about a file descriptor that was added to an fd set.
diff --git a/qmp-commands.hx b/qmp-commands.hx
index b444c20..d4c2ccd 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3930,6 +3930,12 @@ EQMP
 },
 
 {
+.name   = "query-host-cpu",
+.args_type  = "",
+.mhandler.cmd_new = qmp_marshal_query_host_cpu,
+},
+
+{
 .name   = "query-target",
 .args_type  = "",
 .mhandler.cmd_new = qmp_marshal_query_target,
diff --git a/qmp.c b/qmp.c
index 7df6543..aec24d5 100644
--- a/qmp.c
+++ b/qmp.c
@@ -607,6 +607,19 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error 
**errp)
 return arch_query_cpu_definitions(errp);
 }
 
+HostCPUInfo *qmp_query_host_cpu(bool has_migratable, bool migratable,
+Error **errp)
+{
+HostCPUInfo *r = g_new0(HostCPUInfo, 1);
+
+if (!has_migratable) {
+migratable = true;
+}
+
+arch_query_host_cpu_info(r, migratable, errp);
+return r;
+}
+
 void qmp_add_client(const char *protocol, const char *fdname,
 bool has_skipauth, bool skipauth, bool has_tls, bool tls,
 Error **errp)
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 4b258a6..eae0e89 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -1,4 +1,5 @@
 stub-obj-y += arch-query-cpu-def.o
+stub-obj-y += arch-query-host-cpu-info.o
 stub-obj-y += bdrv-next-monitor-owned.o
 stub-obj-y += blk-commit-all.o
 stub-obj-y += blockdev-close-all-bdrv-states.o
diff --git a/stubs/arch-query-host-cpu-info.c b/stubs/arch-query-host-cpu-info.c
new file mode 100644
index 000..b0c455c
--- /dev/null
+++ b/stubs/arch-query-host-cpu-info.c
@@ -0,0 +1,8 @@
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "sysemu/arch_init.h"
+#include "qapi/qmp/qerror.h"
+
+void arch_query_host_cpu_info(HostCPUInfo *r, bool migratable, Error **errp)
+{
+}
-- 
2.5.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/3] qmp: query-host-cpu command

2016-06-20 Thread Eduardo Habkost
Add QMP command to allow management software to query for
CPU information for the running host.

The data returned by the command is in the form of a dictionary
of QOM properties.

This series depends on the "Add runnability info to
query-cpu-definitions" series I sent 2 weeks ago.

Git tree:
  https://github.com/ehabkost/qemu-hacks.git work/query-host-cpu

Example output for x86:

{
"qom-properties": {
"pfthreshold": false,
"pku": false,
"rtm": false,
"tsc-deadline": true,
"xstore-en": false,
"cpuid-0xb": true,
"abm": true,
"ia64": false,
"kvm-mmu": false,
"xsaveopt": true,
"hv-spinlocks": -1,
"hotpluggable": true,
"tce": false,
"smep": true,
"nx": true,
"xcrypt": false,
"sse4_2": true,
"clflush": true,
"sse4_1": true,
"flushbyasid": false,
"kvm-steal-time": true,
"host-cache-info": false,
"tsc": true,
"adx": false,
"ds": false,
"fxsr": true,
"tm": false,
"hv-relaxed": false,
"pclmuldq": true,
"xgetbv1": false,
"xstore": false,
"migratable": true,
"vme": true,
"vendor": "GenuineIntel",
"arat": true,
"ffxsr": false,
"de": true,
"aes": true,
"pse": true,
"ds-cpl": false,
"tbm": false,
"sse": true,
"phe-en": false,
"f16c": true,
"hotplugged": true,
"mpx": false,
"tsc-adjust": true,
"avx512f": false,
"avx2": true,
"misalignsse": false,
"level": 13,
"pbe": false,
"cx16": true,
"avx512pf": false,
"movbe": true,
"perfctr-nb": false,
"enforce": false,
"ospke": false,
"pmu": true,
"fma4": false,
"stepping": 1,
"feature-words": [
{
"cpuid-register": "EAX",
"cpuid-input-eax": 6,
"features": 4
},
{
"cpuid-register": "EAX",
"cpuid-input-eax": 13,
"features": 1,
"cpuid-input-ecx": 1
},
{
"cpuid-register": "EDX",
"cpuid-input-eax": 2147483658,
"features": 0
},
{
"cpuid-register": "EAX",
"cpuid-input-eax": 1073741825,
"features": 16777467
},
{
"cpuid-register": "EDX",
"cpuid-input-eax": 3221225473,
"features": 0
},
{
"cpuid-register": "EDX",
"cpuid-input-eax": 2147483655,
"features": 0
},
{
"cpuid-register": "ECX",
"cpuid-input-eax": 2147483649,
"features": 33
},
{
"cpuid-register": "EDX",
"cpuid-input-eax": 2147483649,
"features": 739248128
},
{
"cpuid-register": "ECX",
"cpuid-input-eax": 7,
"features": 0,
"cpuid-input-ecx": 0
},
{
"cpuid-register": "EBX",
"cpuid-input-eax": 7,
"features": 1963,
"cpuid-input-ecx": 0
},
{
"cpuid-register": "ECX",
"cpuid-input-eax": 1,
"features": 4160369155
},
{
"cpuid-register": "EDX",
"cpuid-input-eax": 1,
"features": 260832255
}
],
"sse4a": false,
"i64": true,
"xsave": true,
"hv-runtime": false,
"pmm": false,
"hle": false,
"hv-crash": false,
"est": false,
"xop": false,
"smx": false,
"tsc-scale": false,
"monitor": false,
"avx512er": false,
"apic": true,
"sse4.1": true,
"sse4.2": true,
"hv-vapic": false,
"pause-filter": false,
"lahf-lm": true,
"kvm-nopiodelay": true,
"acpi": false,
"mmx": true,
"osxsave": false,
 

Re: [libvirt] [PATCH RFC] libxl: set serial source path for console type=serial

2016-06-20 Thread Jim Fehlig
Joao Martins wrote:
> Guests use a  (and sometimes  pair) to represent
> the console. On the callback that is called when console is brought up
> (NB: before domain starts), we fill the path of the console element with
> the appropriate "/dev/pts/X". For PV guests it all works fine, although
> for HVM guests it doesn't. Consequently we end up seeing erronous
> behaviour on HVM guests where console path is not displayed on the XML
> but still can be accessed with virDomainOpenConsole after booting guest.
> Consumers of this XML (e.g. Openstack) also won't be able to use the
> console path.

Can you provide example input domXML config that causes this problem?

Regards,
Jim

> Finally, the path set in consoles array won't persist
> across daemon reboots, thus rendering admins/users with no access to
> console with a message such as:
> 
> "error: operation failed: PTY device is not yet assigned"
> 
> This is because: for HVM guests, DefFormatInternal will ignore the
> console element and instead write it with the content of the serial
> element for target type = serial which isn't touched in our
> libxlConsoleCallback. To address that we introduce a new helper routine
> libxlConsoleSetSourcePath() that sets the source path and thus also
> handling this case. That is by setting the source path on with serial
> element akin to the one indexed by console "port". This way we keep
> similar behaviour for PV and HVM guests.
> 
> Signed-off-by: Joao Martins 
> ---
>  src/libxl/libxl_domain.c | 35 +++
>  1 file changed, 31 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
> index 221af87..4a46143 100644
> --- a/src/libxl/libxl_domain.c
> +++ b/src/libxl/libxl_domain.c
> @@ -955,6 +955,35 @@ libxlNetworkPrepareDevices(virDomainDefPtr def)
>  return 0;
>  }
>  
> +static int
> +libxlConsoleSetSourcePath(virDomainDefPtr def, virDomainChrDefPtr console,
> +  char *path)
> +{
> +int ret = -1;
> +size_t i;
> +
> +if (!path || path[0] == '\0')
> +return ret;
> +
> +if (VIR_STRDUP(console->source.data.file.path, path) < 0)
> +return ret;
> +
> +if (console->targetType != VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)
> +return 0;
> +
> +for (i = 0; i < def->nserials; i++) {
> +virDomainChrDefPtr serial = def->serials[i];
> +
> +if (serial->target.port == console->target.port &&
> +VIR_STRDUP(serial->source.data.file.path, path) >= 0) {
> +ret = 0;
> +break;
> +}
> +}
> +
> +return ret;
> +}
> +
>  static void
>  libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, void *for_callback)
>  {
> @@ -977,10 +1006,8 @@ libxlConsoleCallback(libxl_ctx *ctx, libxl_event *ev, 
> void *for_callback)
>  &console);
>  if (!ret) {
>  VIR_FREE(chr->source.data.file.path);
> -if (console && console[0] != '\0') {
> -ignore_value(VIR_STRDUP(chr->source.data.file.path,
> -console));
> -}
> +if (libxlConsoleSetSourcePath(vm->def, chr, console) < 0)
> +VIR_WARN("Failed to set console source path");
>  }
>  VIR_FREE(console);
>  }

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/1] perf: add more perf events support

2016-06-20 Thread Ren, Qiaowei

> -Original Message-
> From: libvir-list-boun...@redhat.com [mailto:libvir-list-boun...@redhat.com]
> On Behalf Of Ren, Qiaowei
> Sent: Sunday, June 12, 2016 10:14 AM
> To: Peter Krempa 
> Cc: libvir-list@redhat.com
> Subject: Re: [libvirt] [PATCH 1/1] perf: add more perf events support
> 
> > > diff --git a/include/libvirt/libvirt-domain.h
> > > b/include/libvirt/libvirt-domain.h
> > > index cba4fa5..99c4c48 100644
> > > --- a/include/libvirt/libvirt-domain.h
> > > +++ b/include/libvirt/libvirt-domain.h
> > > @@ -1928,6 +1928,45 @@ void
> > virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
> > >   */
> > >  # define VIR_PERF_PARAM_MBML "mbml"
> >
> > [...]
> >
> > > +/**
> > > + * VIR_PERF_PARAM_INSTRUCTIONS:
> > > + *
> > > + * Macro for typed parameter name that represents instructions perf
> > > + * event which can be used to measure the amount of instructions
> > > + * by applications running on the platform. It corresponds to the
> > > + * "perf.instructions" field in the *Stats APIs.
> >
> > I'm not sure if I understand the implications and usability of this stat 
> > parameter.
> > Could you elaborate on how this can be used?
> >
> > > + */
> > > +# define VIR_PERF_PARAM_INSTRUCTIONS "instructions"
> > > +
> > > +/**
> > > + * VIR_PERF_PARAM_CPU_CYCLES:
> > > + *
> > > + * Macro for typed parameter name that represents cpu_cycles perf
> > > +event
> > > + * which can be used to measure how many cycles one instruction needs.
> > > + * It corresponds to the "perf.cpu_cycles" field in the *Stats APIs.
> >
> > And same for this. I don't really see how this can be used.
> >
> 
> Peter, thanks for your feedback!
> 
> Instructions and cycles can be used to gain IPC (Instructions Per Clock, =
> Instructions/Cycles), and a low IPC ratio indicates the code of the process 
> makes
> poor use of the CPU.
> 

Peter, do you have any other comments about this patch?

Thanks,
Qiaowei

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 0/4] Move ccwaddrs and pciaddrs to domainDef

2016-06-20 Thread Tomasz Flendrich

> Apologies if I'm missing something, I didn't look too closely at this series,
> however have you seen this thread?
> 
> http://www.redhat.com/archives/libvir-list/2016-May/msg01071.html
I haven’t noticed that some work has been done on that, thank you!

> My understanding of the current code is that the cached vioserial/ccw/pciaddrs
> lists in qemu aren't actually required…they were at one point to handle

> older qemu, but we dropped that support. Maybe you can pick up my patches and
> finish off dropping of pciaddrs and ccwaddrs? I suspect the pciaddrs cache in
> bhyve can be dropped as well, I don't think it was ever strictly required, the
> code just followed the qemu example
If we could do without the caching, it would make the current code simpler.
There wouldn’t be those booleans in qemu_hotplug.c that remember whether
an address has to be deleted or not in case something fails. We could 
delete qemuDomainReleaseDeviceAddress() and a few more functions.

I examined vioserial and pci addresses and it looks like
it could be done. However, I'm not an expert on qemu_hotplug yet
and this is where the interesting stuff happens with addresses,
so I am not entirely sure yet.
I also don't know what the plans are for device addresses in the future.
Perhaps there are some features that will require caching them.

I think that recalculation may change the current behavior of ccw addresses.
Function virDomainCCWAddressReleaseAddr() modifies addrs->next
only when the address being released was the address most recently
assigned.

Laine, you know a lot about PCI addresses and you also mentioned that
you want to modify them in the future. What do you think?

Martin, should I work on that instead?


Kind regards,
Tomasz

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] is there a plan to support internal-rbd-snapshot?

2016-06-20 Thread longguang.yue
hi, is there a plan to support internal-rbd-snapshot?
any one is responsible  for it?


thanks--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/3] qmp: query-host-cpu command

2016-06-20 Thread David Hildenbrand
> Add QMP command to allow management software to query for
> CPU information for the running host.
> 
> The data returned by the command is in the form of a dictionary
> of QOM properties.
> 
> This series depends on the "Add runnability info to
> query-cpu-definitions" series I sent 2 weeks ago.
> 
> Git tree:
>   https://github.com/ehabkost/qemu-hacks.git work/query-host-cpu
> 

I like that interface, I'm going to post (maybe today? :) ) a similar interface
that allows to also expand other cpu models, not just the host model.

Maybe we can then decide which one makes sense for all of us. But in general,
this interface is much better compared to what we had before. 

David

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list