예제 #1
0
    def _get_osblob_helper(self, guest, isinstall, bootconfig):
        def get_param(obj, paramname):
            if hasattr(obj, paramname):
                return getattr(obj, paramname)
            return None

        ishvm = bool(isinstance(guest, virtinst.FullVirtGuest))
        conn = guest.conn
        arch = self.arch
        loader = get_param(guest, "loader")

        if not isinstall and not ishvm and not self.bootconfig.kernel:
            return "<bootloader>%s</bootloader>" % _util.pygrub_path(conn)

        osblob = "<os>\n"

        os_type = self.os_type
        # Hack for older libvirt: use old value 'linux' for best back compat,
        # new libvirt will adjust the value accordingly.
        if os_type == "xen" and self.type == "xen":
            os_type = "linux"

        osblob += "    <type"
        if arch:
            osblob += " arch='%s'" % arch
        osblob += ">%s</type>\n" % os_type

        if loader:
            osblob += "    <loader>%s</loader>\n" % loader

        osblob += bootconfig.get_xml_config()
        osblob = _util.xml_append(osblob, "  </os>")

        return osblob
예제 #2
0
    def _get_osblob_helper(self, guest, isinstall, bootconfig):
        conn = guest.conn
        arch = self.arch
        machine = self.machine
        hvtype = self.type
        loader = self.loader
        os_type = self.os_type
        init = self.init or self._get_default_init(guest)

        hvxen = (hvtype == "xen")

        if not loader and self.is_hvm() and hvxen:
            loader = "/usr/lib/xen/boot/hvmloader"

        # Use older libvirt 'linux' value for back compat
        if os_type == "xen" and hvxen:
            os_type = "linux"

        if (not isinstall and
            self.is_xenpv() and
            not self.bootconfig.kernel):
            return "<bootloader>%s</bootloader>" % _util.pygrub_path(conn)

        osblob = "<os>"

        typexml = "    <type"
        if arch:
            typexml += " arch='%s'" % arch
        if machine:
            typexml += " machine='%s'" % machine
        typexml += ">%s</type>" % os_type

        osblob = _util.xml_append(osblob, typexml)

        if init:
            osblob = _util.xml_append(osblob,
                                      "    <init>%s</init>" %
                                      _util.xml_escape(init))
        if loader:
            osblob = _util.xml_append(osblob,
                                      "    <loader>%s</loader>" %
                                      _util.xml_escape(loader))

        if not self.is_container():
            osblob = _util.xml_append(osblob, bootconfig.get_xml_config())
        osblob = _util.xml_append(osblob, "  </os>")

        return osblob
예제 #3
0
    def _get_osblob_helper(self, guest, isinstall, bootconfig):
        conn = guest.conn
        arch = self.arch
        machine = self.machine
        hvtype = self.type
        loader = self.loader
        os_type = self.os_type
        init = self.init or self._get_default_init(guest)

        hvxen = (hvtype == "xen")

        if not loader and self.is_hvm() and hvxen:
            loader = "/usr/lib/xen/boot/hvmloader"

        # Use older libvirt 'linux' value for back compat
        if os_type == "xen" and hvxen:
            os_type = "linux"

        if (not isinstall and
            self.is_xenpv() and
            not self.bootconfig.kernel):
            return "<bootloader>%s</bootloader>" % _util.pygrub_path(conn)

        osblob = "<os>"

        typexml = "    <type"
        if arch:
            typexml += " arch='%s'" % arch
        if machine:
            typexml += " machine='%s'" % machine
        typexml += ">%s</type>" % os_type

        osblob = _util.xml_append(osblob, typexml)

        if init:
            osblob = _util.xml_append(osblob,
                                      "    <init>%s</init>" %
                                      _util.xml_escape(init))
        if loader:
            osblob = _util.xml_append(osblob,
                                      "    <loader>%s</loader>" %
                                      _util.xml_escape(loader))

        if not self.is_container():
            osblob = _util.xml_append(osblob, bootconfig.get_xml_config())
        osblob = _util.xml_append(osblob, "  </os>")

        return osblob