[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Re: [PATCH] [XM] Conversion of vtpm and access_control information




xen-devel-bounces@xxxxxxxxxxxxxxxxxxx wrote on 04/05/2007 01:48:57 PM:

> On Mon, Apr 02, 2007 at 03:56:10PM -0400, Stefan Berger wrote:
>
> > This patch converts vTPM and access_control lines in the (old-style) vm
> > config files so a VM can be created using the Xen-API.
> > I extended the DTD to the best of my knowledge, but to use xm with
> > Xen-API I have to disable the DTD checking (skipdtd).
>
> What error do you get from the DTD checking?  It shouldn't be too hard to make
> this work properly.


Using config file "/etc/xen/testvm-1".
ERROR: Couldn't open resource '/usr/lib/python/xen/xm/create.dtd' at
/usr/lib/python/xen/xm/create.dtd:1:0
Element 'xm' not declared

I get this error also without this patch.

   Stefan

>
> Ewan.
>
>
> >
> > Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
> >
>
> > Index: root/xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
> > ===================================================================
> > --- root.orig/xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
> > +++ root/xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
> > @@ -265,9 +265,15 @@ class xenapi_create:
> >              "platform":
> >                  get_child_nodes_as_dict(vm, "platform", "key", "value"),
> >              "other_config":
> > -                get_child_nodes_as_dict(vm, "other_config", "key", "value")
> > +                get_child_nodes_as_dict(vm, "other_config",
> "key", "value"),
> >              }
> >  
> > +        if vm.attributes.has_key("security_label"):
> > +            vm_record.update({
> > +                "security_label":
> > +                    vm.attributes["security_label"].value
> > +                })
> > +
> >          if len(vm.getElementsByTagName("pv")) > 0:
> >              vm_record.update({
> >                  "PV_bootloader":
> > @@ -308,6 +314,12 @@ class xenapi_create:
> >  
> >              self.create_vifs(vm_ref, vifs)
> >  
> > +            # Now create vtpms
> > +
> > +            vtpms = vm.getElementsByTagName("vtpm")
> > +
> > +            self.create_vtpms(vm_ref, vtpms)
> > +
> >              # Now create consoles
> >  
> >              consoles = vm.getElementsByTagName("console")
> > @@ -397,6 +409,21 @@ class xenapi_create:
> >              self._network_refs = server.xenapi.network.get_all()
> >              return self._network_refs.pop(0)
> >  
> > +    def create_vtpms(self, vm_ref, vtpms):
> > +        if len(vtpms) > 1:
> > +            vtpms = [ vtpms[0] ]
> > +        log(DEBUG, "create_vtpms")
> > +        return map(lambda vtpm: self.create_vtpm(vm_ref, vtpm), vtpms)
> > +
> > +    def create_vtpm(self, vm_ref, vtpm):
> > +        vtpm_record = {
> > +            "VM":
> > +                vm_ref,
> > +            "backend":
> > +                vtpm.attributes["backend"].value
> > +        }
> > +        return server.xenapi.VTPM.create(vtpm_record)
> > +
> >      def create_consoles(self, vm_ref, consoles):
> >          log(DEBUG, "create_consoles")
> >          return map(lambda console: self.create_console(vm_ref, console),
> > @@ -438,6 +465,10 @@ class sxp2xml:
> >  
> >          vifs_sxp = map(lambda x: x[1], [device for device in devices
> >                                          if device[1][0] == "vif"])
> > +
> > +        vtpms_sxp = map(lambda x: x[1], [device for device in devices
> > +                                         if device[1][0] == "vtpm"])
> > +
> >          # Create XML Document
> >          
> >          impl = getDOMImplementation()
> > @@ -487,6 +518,14 @@ class sxp2xml:
> >          vm.attributes["vcpus_at_startup"] \
> >              = str(get_child_by_name(config, "vcpus", 1))
> >  
> > +        sec_data = get_child_by_name(config, "security")
> > +        if sec_data:
> > +            try :
> > +                vm.attributes['security_label'] = \
> > +                      "sHype:%s:%s" % (sec_data[0][1][1],sec_data[0][2][1])
> > +            except:
> > +                raise "Invalid security data format: %s" % str(sec_data)
> > +
> >          # Make the name tag
> >  
> >          vm.appendChild(self.make_name_tag(
> > @@ -557,6 +596,12 @@ class sxp2xml:
> >  
> >          map(vm.appendChild, vifs)
> >  
> > +        # And now the vTPMs
> > +
> > +        vtpms = map(lambda vtpm: self.extract_vtpm(vtpm,
> document), vtpms_sxp)
> > +
> > +        map(vm.appendChild, vtpms)
> > +
> >          # Last but not least the consoles...
> >  
> >          consoles = self.extract_consoles(image, document)
> > @@ -664,6 +709,14 @@ class sxp2xml:
> >          
> >          return vif
> >  
> > +    def extract_vtpm(self, vtpm_sxp, document):
> > +
> > +        vtpm = document.createElement("vtpm")
> > +        vtpm.attributes["backend"] \
> > +             = get_child_by_name(vtpm_sxp, "backend", "0")
> > +
> > +        return vtpm
> > +
> >      _eths = -1
> >  
> >      def mk_other_config(self, key, value, document):
> > Index: root/xen-unstable.hg/tools/python/xen/xm/create.dtd
> > ===================================================================
> > --- root.orig/xen-unstable.hg/tools/python/xen/xm/create.dtd
> > +++ root/xen-unstable.hg/tools/python/xen/xm/create.dtd
> > @@ -37,6 +37,7 @@
> >                   memory,
> >                   vbd*,
> >                   vif*,
> > +                 vtpm*,
> >                   console*,
> >                   platform*,
> >                   vcpu_param*,
> > @@ -73,6 +74,10 @@
> >                   qos_algorithm_type CDATA    #REQUIRED
> >                   network         CDATA       #IMPLIED>
> >  
> > +<!ELEMENT vtpm   (name)>
> > +<!ATTLIST vtpm   %NAMEID;
> > +                 backend         CDATA #REQUIRED>
> > +
> >  <!ELEMENT console (other_config*)>
> >  <!ATTLIST console protocol       (vt100|rfb|rdp) #REQUIRED>
> >  
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.