Richard W.M. Jones
2017-Mar-16 19:13 UTC
[Libguestfs] [PATCH] v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology.
--- v2v/parse_libvirt_xml.ml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/v2v/parse_libvirt_xml.ml b/v2v/parse_libvirt_xml.ml index 6032c31..fb895e4 100644 --- a/v2v/parse_libvirt_xml.ml +++ b/v2v/parse_libvirt_xml.ml @@ -50,7 +50,7 @@ let parse_libvirt_xml ?conn xml let xpathctx = Xml.xpath_new_context doc in let xpath_string = xpath_string xpathctx and xpath_int = xpath_int xpathctx - and xpath_int_default = xpath_int_default xpathctx + (*and xpath_int_default = xpath_int_default xpathctx*) and xpath_int64_default = xpath_int64_default xpathctx in let hypervisor @@ -65,7 +65,6 @@ let parse_libvirt_xml ?conn xml | Some s -> s in let memory = xpath_int64_default "/domain/memory/text()" (1024L *^ 1024L) in let memory = memory *^ 1024L in - let vcpu = xpath_int_default "/domain/vcpu/text()" 1 in let cpu_vendor = xpath_string "/domain/cpu/vendor/text()" in let cpu_model = xpath_string "/domain/cpu/model/text()" in @@ -73,6 +72,21 @@ let parse_libvirt_xml ?conn xml let cpu_cores = xpath_int "/domain/cpu/topology/@cores" in let cpu_threads = xpath_int "/domain/cpu/topology/@threads" in + (* Get the <vcpu> field from the input XML. If not set then + * try calculating it from the <cpu> <topology> node. If that's + * not set either, then assume 1 vCPU. + *) + let vcpu = xpath_int "/domain/vcpu/text()" in + let vcpu + match vcpu, cpu_sockets, cpu_cores, cpu_threads with + | Some vcpu, _, _, _ -> vcpu + | None, None, None, None -> 1 + | None, _, _, _ -> + let sockets = match cpu_sockets with None -> 1 | Some v -> v in + let cores = match cpu_cores with None -> 1 | Some v -> v in + let threads = match cpu_threads with None -> 1 | Some v -> v in + sockets * cores * threads in + let features let features = ref [] in let obj = Xml.xpath_eval_expression xpathctx "/domain/features/*" in -- 2.10.2
Richard W.M. Jones
2017-Mar-16 20:55 UTC
Re: [Libguestfs] [PATCH] v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology.
On Thu, Mar 16, 2017 at 07:13:12PM +0000, Richard W.M. Jones wrote:> + (* Get the <vcpu> field from the input XML. If not set then > + * try calculating it from the <cpu> <topology> node. If that's > + * not set either, then assume 1 vCPU. > + *) > + let vcpu = xpath_int "/domain/vcpu/text()" in > + let vcpu > + match vcpu, cpu_sockets, cpu_cores, cpu_threads with > + | Some vcpu, _, _, _ -> vcpu > + | None, None, None, None -> 1 > + | None, _, _, _ -> > + let sockets = match cpu_sockets with None -> 1 | Some v -> v in > + let cores = match cpu_cores with None -> 1 | Some v -> v in > + let threads = match cpu_threads with None -> 1 | Some v -> v in > + sockets * cores * threads inOoops, this hunk is wrong. I'll post a v2 once I fix it. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Richard W.M. Jones
2017-Mar-16 21:09 UTC
Re: [Libguestfs] [PATCH] v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology.
On Thu, Mar 16, 2017 at 08:55:41PM +0000, Richard W.M. Jones wrote:> On Thu, Mar 16, 2017 at 07:13:12PM +0000, Richard W.M. Jones wrote: > > + (* Get the <vcpu> field from the input XML. If not set then > > + * try calculating it from the <cpu> <topology> node. If that's > > + * not set either, then assume 1 vCPU. > > + *) > > + let vcpu = xpath_int "/domain/vcpu/text()" in > > + let vcpu > > + match vcpu, cpu_sockets, cpu_cores, cpu_threads with > > + | Some vcpu, _, _, _ -> vcpu > > + | None, None, None, None -> 1 > > + | None, _, _, _ -> > > + let sockets = match cpu_sockets with None -> 1 | Some v -> v in > > + let cores = match cpu_cores with None -> 1 | Some v -> v in > > + let threads = match cpu_threads with None -> 1 | Some v -> v in > > + sockets * cores * threads in > > Ooops, this hunk is wrong. I'll post a v2 once I fix it.In fact it's the test which was wrong. Patch v2 posted in a new thread. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Apparently Analagous Threads
- [PATCH v2] v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology.
- Re: [PATCH v2] v2v: -i libvirt: If <vcpu> is missing, calculate it from CPU topology.
- [PATCH 4/4] v2v: Pass CPU vendor, model and topology from source to target.
- [PATCH v2 4/4] common/mltools: xpath_helpers: Get rid of xpath_*_default functions.
- [PATCH] v2v: Add xpath_int64 functions, and use them to read memory values.