Shahar Havivi
2014-Aug-25 09:39 UTC
[Libguestfs] do we have support for xmlns in xml for v2v?
Hi, I need to parse xml (vmware ovf) which have a namespace. Attached the ovf file. Thanks, Shahar.
Richard W.M. Jones
2014-Aug-25 10:33 UTC
Re: [Libguestfs] do we have support for xmlns in xml for v2v?
On Mon, Aug 25, 2014 at 12:39:24PM +0300, Shahar Havivi wrote:> Hi, > > I need to parse xml (vmware ovf) which have a namespace. > Attached the ovf file.Yes, libxml2 should be able to handle any aspect of XML. Probably it's best to use XPath expressions, see for example src/input_libvirt.ml. If you need new libxml2 APIs to be added to src/xml-c.c then you can have a go yourself or ask Pino to write any you need. Rich.> Thanks, > Shahar.> <?xml version="1.0" encoding="UTF-8"?> > <!--Generated by VMware ESX Server, User: root, UTC time: 2014-08-12T13:33:20.142834Z--> > <Envelope vmw:buildId="build-1623387" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <References> > <File ovf:href="First-disk1.vmdk" ovf:id="file1" ovf:size="349405696" /> > </References> > <DiskSection> > <Info>Virtual disk information</Info> > <Disk ovf:capacity="32" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="1008926720" /> > </DiskSection> > <NetworkSection> > <Info>The list of logical networks</Info> > <Network ovf:name="VM Network"> > <Description>The VM Network network</Description> > </Network> > </NetworkSection> > <VirtualSystem ovf:id="First"> > <Info>A virtual machine</Info> > <Name>First</Name> > <OperatingSystemSection ovf:id="74" vmw:osType="windows7_64Guest"> > <Info>The kind of installed guest operating system</Info> > </OperatingSystemSection> > <VirtualHardwareSection> > <Info>Virtual hardware requirements</Info> > <System> > <vssd:ElementName>Virtual Hardware Family</vssd:ElementName> > <vssd:InstanceID>0</vssd:InstanceID> > <vssd:VirtualSystemIdentifier>First</vssd:VirtualSystemIdentifier> > <vssd:VirtualSystemType>vmx-08</vssd:VirtualSystemType> > </System> > <Item> > <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> > <rasd:Description>Number of Virtual CPUs</rasd:Description> > <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName> > <rasd:InstanceID>1</rasd:InstanceID> > <rasd:ResourceType>3</rasd:ResourceType> > <rasd:VirtualQuantity>1</rasd:VirtualQuantity> > </Item> > <Item> > <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits> > <rasd:Description>Memory Size</rasd:Description> > <rasd:ElementName>2048MB of memory</rasd:ElementName> > <rasd:InstanceID>2</rasd:InstanceID> > <rasd:ResourceType>4</rasd:ResourceType> > <rasd:VirtualQuantity>2048</rasd:VirtualQuantity> > </Item> > <Item> > <rasd:Address>0</rasd:Address> > <rasd:Description>SCSI Controller</rasd:Description> > <rasd:ElementName>SCSI Controller 0</rasd:ElementName> > <rasd:InstanceID>3</rasd:InstanceID> > <rasd:ResourceSubType>lsilogicsas</rasd:ResourceSubType> > <rasd:ResourceType>6</rasd:ResourceType> > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="160" /> > </Item> > <Item> > <rasd:Address>1</rasd:Address> > <rasd:Description>IDE Controller</rasd:Description> > <rasd:ElementName>VirtualIDEController 1</rasd:ElementName> > <rasd:InstanceID>4</rasd:InstanceID> > <rasd:ResourceType>5</rasd:ResourceType> > </Item> > <Item> > <rasd:Address>0</rasd:Address> > <rasd:Description>IDE Controller</rasd:Description> > <rasd:ElementName>VirtualIDEController 0</rasd:ElementName> > <rasd:InstanceID>5</rasd:InstanceID> > <rasd:ResourceType>5</rasd:ResourceType> > </Item> > <Item ovf:required="false"> > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > <rasd:ElementName>VirtualVideoCard</rasd:ElementName> > <rasd:InstanceID>6</rasd:InstanceID> > <rasd:ResourceType>24</rasd:ResourceType> > <vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="enableMPTSupport" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic" /> > <vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="8192" /> > </Item> > <Item ovf:required="false"> > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > <rasd:ElementName>VirtualVMCIDevice</rasd:ElementName> > <rasd:InstanceID>7</rasd:InstanceID> > <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType> > <rasd:ResourceType>1</rasd:ResourceType> > <vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="33" /> > </Item> > <Item ovf:required="false"> > <rasd:AddressOnParent>0</rasd:AddressOnParent> > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > <rasd:ElementName>CD-ROM 1</rasd:ElementName> > <rasd:InstanceID>8</rasd:InstanceID> > <rasd:Parent>4</rasd:Parent> > <rasd:ResourceSubType>vmware.cdrom.iso</rasd:ResourceSubType> > <rasd:ResourceType>15</rasd:ResourceType> > </Item> > <Item> > <rasd:AddressOnParent>0</rasd:AddressOnParent> > <rasd:ElementName>Hard Disk 1</rasd:ElementName> > <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource> > <rasd:InstanceID>9</rasd:InstanceID> > <rasd:Parent>3</rasd:Parent> > <rasd:ResourceType>17</rasd:ResourceType> > <vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false" /> > </Item> > <Item ovf:required="false"> > <rasd:AddressOnParent>0</rasd:AddressOnParent> > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > <rasd:Description>Floppy Drive</rasd:Description> > <rasd:ElementName>Floppy 1</rasd:ElementName> > <rasd:InstanceID>10</rasd:InstanceID> > <rasd:ResourceSubType>vmware.floppy.remotedevice</rasd:ResourceSubType> > <rasd:ResourceType>14</rasd:ResourceType> > </Item> > <Item> > <rasd:AddressOnParent>7</rasd:AddressOnParent> > <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> > <rasd:Connection>VM Network</rasd:Connection> > <rasd:Description>E1000 ethernet adapter on "VM Network"</rasd:Description> > <rasd:ElementName>Ethernet 1</rasd:ElementName> > <rasd:InstanceID>11</rasd:InstanceID> > <rasd:ResourceSubType>E1000</rasd:ResourceSubType> > <rasd:ResourceType>10</rasd:ResourceType> > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="32" /> > <vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true" /> > </Item> > <vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios" /> > <vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft" /> > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft" /> > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint" /> > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="hard" /> > <vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true" /> > <vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true" /> > <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true" /> > <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true" /> > <vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false" /> > <vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="manual" /> > </VirtualHardwareSection> > </VirtualSystem> > </Envelope>-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Richard W.M. Jones
2014-Aug-25 10:36 UTC
Re: [Libguestfs] do we have support for xmlns in xml for v2v?
On Mon, Aug 25, 2014 at 11:33:53AM +0100, Richard W.M. Jones wrote:> On Mon, Aug 25, 2014 at 12:39:24PM +0300, Shahar Havivi wrote: > > Hi, > > > > I need to parse xml (vmware ovf) which have a namespace. > > Attached the ovf file. > > Yes, libxml2 should be able to handle any aspect of XML. > > Probably it's best to use XPath expressions, see for example > src/input_libvirt.ml.s{src}{v2v}> > If you need new libxml2 APIs to be added to src/xml-c.c then you cans{src}{v2v}> have a go yourself or ask Pino to write any you need. > > Rich. > > > Thanks, > > Shahar. > > > <?xml version="1.0" encoding="UTF-8"?> > > <!--Generated by VMware ESX Server, User: root, UTC time: 2014-08-12T13:33:20.142834Z--> > > <Envelope vmw:buildId="build-1623387" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <References> > > <File ovf:href="First-disk1.vmdk" ovf:id="file1" ovf:size="349405696" /> > > </References> > > <DiskSection> > > <Info>Virtual disk information</Info> > > <Disk ovf:capacity="32" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="1008926720" /> > > </DiskSection> > > <NetworkSection> > > <Info>The list of logical networks</Info> > > <Network ovf:name="VM Network"> > > <Description>The VM Network network</Description> > > </Network> > > </NetworkSection> > > <VirtualSystem ovf:id="First"> > > <Info>A virtual machine</Info> > > <Name>First</Name> > > <OperatingSystemSection ovf:id="74" vmw:osType="windows7_64Guest"> > > <Info>The kind of installed guest operating system</Info> > > </OperatingSystemSection> > > <VirtualHardwareSection> > > <Info>Virtual hardware requirements</Info> > > <System> > > <vssd:ElementName>Virtual Hardware Family</vssd:ElementName> > > <vssd:InstanceID>0</vssd:InstanceID> > > <vssd:VirtualSystemIdentifier>First</vssd:VirtualSystemIdentifier> > > <vssd:VirtualSystemType>vmx-08</vssd:VirtualSystemType> > > </System> > > <Item> > > <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> > > <rasd:Description>Number of Virtual CPUs</rasd:Description> > > <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName> > > <rasd:InstanceID>1</rasd:InstanceID> > > <rasd:ResourceType>3</rasd:ResourceType> > > <rasd:VirtualQuantity>1</rasd:VirtualQuantity> > > </Item> > > <Item> > > <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits> > > <rasd:Description>Memory Size</rasd:Description> > > <rasd:ElementName>2048MB of memory</rasd:ElementName> > > <rasd:InstanceID>2</rasd:InstanceID> > > <rasd:ResourceType>4</rasd:ResourceType> > > <rasd:VirtualQuantity>2048</rasd:VirtualQuantity> > > </Item> > > <Item> > > <rasd:Address>0</rasd:Address> > > <rasd:Description>SCSI Controller</rasd:Description> > > <rasd:ElementName>SCSI Controller 0</rasd:ElementName> > > <rasd:InstanceID>3</rasd:InstanceID> > > <rasd:ResourceSubType>lsilogicsas</rasd:ResourceSubType> > > <rasd:ResourceType>6</rasd:ResourceType> > > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="160" /> > > </Item> > > <Item> > > <rasd:Address>1</rasd:Address> > > <rasd:Description>IDE Controller</rasd:Description> > > <rasd:ElementName>VirtualIDEController 1</rasd:ElementName> > > <rasd:InstanceID>4</rasd:InstanceID> > > <rasd:ResourceType>5</rasd:ResourceType> > > </Item> > > <Item> > > <rasd:Address>0</rasd:Address> > > <rasd:Description>IDE Controller</rasd:Description> > > <rasd:ElementName>VirtualIDEController 0</rasd:ElementName> > > <rasd:InstanceID>5</rasd:InstanceID> > > <rasd:ResourceType>5</rasd:ResourceType> > > </Item> > > <Item ovf:required="false"> > > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > > <rasd:ElementName>VirtualVideoCard</rasd:ElementName> > > <rasd:InstanceID>6</rasd:InstanceID> > > <rasd:ResourceType>24</rasd:ResourceType> > > <vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="enableMPTSupport" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic" /> > > <vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="8192" /> > > </Item> > > <Item ovf:required="false"> > > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > > <rasd:ElementName>VirtualVMCIDevice</rasd:ElementName> > > <rasd:InstanceID>7</rasd:InstanceID> > > <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType> > > <rasd:ResourceType>1</rasd:ResourceType> > > <vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="33" /> > > </Item> > > <Item ovf:required="false"> > > <rasd:AddressOnParent>0</rasd:AddressOnParent> > > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > > <rasd:ElementName>CD-ROM 1</rasd:ElementName> > > <rasd:InstanceID>8</rasd:InstanceID> > > <rasd:Parent>4</rasd:Parent> > > <rasd:ResourceSubType>vmware.cdrom.iso</rasd:ResourceSubType> > > <rasd:ResourceType>15</rasd:ResourceType> > > </Item> > > <Item> > > <rasd:AddressOnParent>0</rasd:AddressOnParent> > > <rasd:ElementName>Hard Disk 1</rasd:ElementName> > > <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource> > > <rasd:InstanceID>9</rasd:InstanceID> > > <rasd:Parent>3</rasd:Parent> > > <rasd:ResourceType>17</rasd:ResourceType> > > <vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false" /> > > </Item> > > <Item ovf:required="false"> > > <rasd:AddressOnParent>0</rasd:AddressOnParent> > > <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> > > <rasd:Description>Floppy Drive</rasd:Description> > > <rasd:ElementName>Floppy 1</rasd:ElementName> > > <rasd:InstanceID>10</rasd:InstanceID> > > <rasd:ResourceSubType>vmware.floppy.remotedevice</rasd:ResourceSubType> > > <rasd:ResourceType>14</rasd:ResourceType> > > </Item> > > <Item> > > <rasd:AddressOnParent>7</rasd:AddressOnParent> > > <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> > > <rasd:Connection>VM Network</rasd:Connection> > > <rasd:Description>E1000 ethernet adapter on "VM Network"</rasd:Description> > > <rasd:ElementName>Ethernet 1</rasd:ElementName> > > <rasd:InstanceID>11</rasd:InstanceID> > > <rasd:ResourceSubType>E1000</rasd:ResourceSubType> > > <rasd:ResourceType>10</rasd:ResourceType> > > <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="32" /> > > <vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true" /> > > </Item> > > <vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios" /> > > <vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft" /> > > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft" /> > > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint" /> > > <vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="hard" /> > > <vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true" /> > > <vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true" /> > > <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true" /> > > <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true" /> > > <vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false" /> > > <vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="manual" /> > > </VirtualHardwareSection> > > </VirtualSystem> > > </Envelope> > > > -- > Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > libguestfs lets you edit virtual machines. Supports shell scripting, > bindings from many languages. http://libguestfs.org > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- 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
2014-Aug-25 10:43 UTC
Re: [Libguestfs] do we have support for xmlns in xml for v2v?
I don't think I've parsed a namespaced document using xpath before, but according to: https://stackoverflow.com/questions/3135175/libxml2-error-with-namespaces-and-xpath it looks like you'll need a binding for xmlXPathRegisterNs. 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/