On Thu, May 28, 2009 at 9:03 AM, Cole Robinson <crobinso@xxxxxxxxxx> wrote: > Mark Johnson wrote: >> >> For Solaris dom0, I have a patch that allows driver and subdriver in >> virt-install. >> If interested, I'm happy to submit it..Note, our blktap is different >> (vdisk). We >> have an additional format selection too. >> >> virt-install -p -n nevada -l /export/snv108.iso --nographics \ >> --noautoconsole -r 1024 \ >> --disk path=/export/nevada/disk0,size=10,driver=tap,subdriver=vdisk,format=vdi >> >> >> MRJ > > Sounds like a reasonable addition to me. I'd be interested in a patch. > Driver/subdriver and format should probably be two different patches though. OK. For now, I've attached our current patch for reference.. Not meant for submission. I'm not sure how far behind virt-install we are these days. FYI, It has more than just the tap stuff. We also support iscsi, etc.. e.g. we support the following iscsi paths... phy:iscsi:/alias/<iscsi-alias> phy:iscsi:/static/<server IP>/<lun>/<target id> phy:iscsi:/discover/<lun>/<alias or target id> virt-install -p -n nevada -l /export/snv108.iso --nographics \ --noautoconsole -r 1024 \ --disk path=/alias/tank/iscsi/nevada/disk0,driver=phy,subdriver=iscsi
diff --git a/virt-install b/virt-install --- a/virt-install +++ b/virt-install @@ -81,6 +81,9 @@ sparse = True bus = None cache = None + driver = None + subdriver = None + format = None # Strip media type if path.startswith("path="): @@ -133,6 +136,12 @@ fail(_("Unknown '%s' value '%s'") % (opt_type, opt_val)) elif opt_type == "cache": cache = opt_val + elif opt_type == "driver": + driver = opt_val + elif opt_type == "subdriver": + subdriver = opt_val + elif opt_type == "format": + format = opt_val else: fail(_("Unknown --disk option '%s'.") % (opt,)) @@ -169,7 +178,7 @@ if not devtype: devtype = virtinst.VirtualDisk.DEVICE_DISK ret = (abspath, voltuple, volinst, devtype, bus, ro, shared, size, sparse, - cache) + cache, driver, subdriver, format) logging.debug("parse_disk: returning %s" % str(ret)) return ret @@ -179,13 +188,14 @@ # Get disk parameters if is_file_path: (path, voltuple, volinst, device, bus, readOnly, shared, size, - sparse, cache) = \ + sparse, cache, driver, subdriver, format) = \ (disk, None, None, virtinst.VirtualDisk.DEVICE_DISK, None, False, - False, size, sparse, None) + False, size, sparse, None, None, None, None) else: (path, voltuple, volinst, device, bus, readOnly, shared, - size, sparse, cache) = parse_disk_option(guest, disk, size) + size, sparse, cache, driver, subdriver, format) = \ + parse_disk_option(guest, disk, size) if not sparse and volinst: volinst.allocation = volinst.capacity @@ -193,7 +203,8 @@ volInstall=volinst, volName=voltuple, readOnly=readOnly, shareable=shared, device=device, bus=bus, conn=guest.conn, - driverCache=cache) + driverCache=cache, driverName=driver, + driverType=subdriver, format=format) # Default file backed PV guests to tap driver if d.type == virtinst.VirtualDisk.TYPE_FILE \ and not(hvm) and virtinst.util.is_blktap_capable(): diff --git a/virtinst/CloneManager.py b/virtinst/CloneManager.py --- a/virtinst/CloneManager.py +++ b/virtinst/CloneManager.py @@ -531,10 +531,10 @@ clone_type = IS_UNKNOWN - if (_util.is_vdisk(src_path) or - (os.path.exists(dst_path) and _util.is_vdisk(dst_path))): + if (_util.is_vdisk(src_path, None) or + (os.path.exists(dst_path) and _util.is_vdisk(dst_path, None))): - if (not _util.is_vdisk(src_path) or + if (not _util.is_vdisk(src_path, None) or os.path.exists(dst_path)): raise RuntimeError, _("copying to an existing vdisk is not" " supported") diff --git a/virtinst/Installer.py b/virtinst/Installer.py --- a/virtinst/Installer.py +++ b/virtinst/Installer.py @@ -293,7 +293,7 @@ or guest.disks[0].device != VirtualDisk.DEVICE_DISK: return True - if _util.is_vdisk(guest.disks[0].path): + if _util.is_vdisk(guest.disks[0].path, None): return True # Check for the 0xaa55 signature at the end of the MBR diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py --- a/virtinst/VirtualDisk.py +++ b/virtinst/VirtualDisk.py @@ -28,6 +28,15 @@ import Storage from VirtualDevice import VirtualDevice from virtinst import _virtinst as _ + +def _zvol_create(path, size): + zvol = path.lstrip("/") + try: + rc = subprocess.call(['/usr/sbin/zfs', 'create', '-p', '-V', + str(size), zvol]) + return rc == 0 + except OSError: + return False def _vdisk_create(path, size, kind, sparse = True): force_fixed = "raw" @@ -83,8 +92,17 @@ DRIVER_TAP_QCOW = "qcow" DRIVER_TAP_VMDK = "vmdk" DRIVER_TAP_VDISK = "vdisk" + + DRIVER_PHY_ISCSI = "iscsi" + DRIVER_PHY_ZVOL = "zvol" + DRIVER_PHY_ZPOOL = "zpool" + DRIVER_PHY_NPIV = "npiv" + DRIVER_PHY_SAN = "san" + driver_types = [DRIVER_TAP_RAW, DRIVER_TAP_QCOW, - DRIVER_TAP_VMDK, DRIVER_TAP_VDISK] + DRIVER_TAP_VMDK, DRIVER_TAP_VDISK, + DRIVER_PHY_ISCSI, DRIVER_PHY_ZVOL, DRIVER_PHY_ZPOOL, + DRIVER_PHY_NPIV, DRIVER_PHY_SAN] CACHE_MODE_NONE = "none" CACHE_MODE_WRITETHROUGH = "writethrough" @@ -105,7 +123,7 @@ device=DEVICE_DISK, driverName=None, driverType=None, readOnly=False, sparse=True, conn=None, volObject=None, volInstall=None, volName=None, bus=None, shareable=False, - driverCache=None): + driverCache=None, format=None): """ @param path: filesystem path to the disk image. @type path: C{str} @@ -140,6 +158,8 @@ @type shareable: C{bool} @param driverCache: Disk cache mode (none, writethrough, writeback) @type driverCache: member of cache_types + @param format: driver-specific format to use during create + @type format: C{str} """ VirtualDevice.__init__(self, conn=conn) @@ -161,6 +181,7 @@ self._driverName = driverName self._driverType = driverType self.target = None + self.format = format self.set_read_only(readOnly, validate=False) self.set_sparse(sparse, validate=False) @@ -358,11 +379,13 @@ # All others should be using TYPE_BLOCK (hopefully) dtype = self.TYPE_BLOCK elif self.path: - if _util.stat_disk(self.path)[0]: + if self._driverName == self.DRIVER_PHY: + dtype = self.TYPE_BLOCK + elif _util.stat_disk(self.path)[0]: dtype = self.TYPE_FILE else: dtype = self.TYPE_BLOCK - if _util.is_vdisk(self.path): + if _util.is_vdisk(self.path, self._driverName): self._driverName = self.DRIVER_TAP self._driverType = self.DRIVER_TAP_VDISK @@ -553,7 +576,7 @@ if not create_media: # Make sure we have access to the local path if not managed_storage: - if os.path.isdir(self.path) and not _util.is_vdisk(self.path): + if os.path.isdir(self.path) and not _util.is_vdisk(self.path, self._driverName): # vdisk _is_ a directory. raise ValueError(_("The path '%s' must be a file or a " "device, not a directory") % self.path) @@ -568,7 +591,7 @@ raise ValueError, _("Cannot create storage for %s device.") % \ self.device - if not managed_storage: + if not managed_storage and not self._driverType: if self.type is self.TYPE_BLOCK: raise ValueError, _("Local block device path must exist.") self.set_type(self.TYPE_FILE, validate=False) @@ -611,6 +634,13 @@ self._set_vol_object(self.vol_install.install(meter=progresscb), validate=False) return + + elif self._driverName == self.DRIVER_PHY and self._driverType: + if self._driverType == self.DRIVER_PHY_ZVOL: + size_bytes = long(self.size * 1024L * 1024L * 1024L) + if (not _zvol_create(self.path, size_bytes)): + raise RuntimeError, _("Error creating zvol %s" % self.path) + elif (self.type == VirtualDisk.TYPE_FILE and self.path is not None and not os.path.exists(self.path)): size_bytes = long(self.size * 1024L * 1024L * 1024L) @@ -619,9 +649,11 @@ progresscb.start(filename=self.path,size=long(size_bytes), \ text=_("Creating storage file...")) - if _util.is_vdisk(self.path): + if _util.is_vdisk(self.path, self._driverName): progresscb.update(1024) - if (not _vdisk_create(self.path, size_bytes, "vmdk", + if self.format is None: + self.format = "vmdk" + if (not _vdisk_create(self.path, size_bytes, self.format, self.sparse)): raise RuntimeError, _("Error creating vdisk %s" % self.path) self._driverName = self.DRIVER_TAP diff --git a/virtinst/_util.py b/virtinst/_util.py --- a/virtinst/_util.py +++ b/virtinst/_util.py @@ -34,10 +34,12 @@ from virtinst import util from virtinst import _virtinst as _ -def is_vdisk(path): +def is_vdisk(path, driver): if not os.path.exists("/usr/sbin/vdiskadm"): return False - if not os.path.exists(path): + if driver == "tap": + return True + if driver is None and not os.path.exists(path): return True if os.path.isdir(path) and \ os.path.exists(path + "/vdisk.xml"): @@ -49,7 +51,7 @@ if not os.path.exists(path): return True, 0 - if is_vdisk(path): + if is_vdisk(path, None): size = int(commands.getoutput( "vdiskadm prop-get -p max-size " + path)) return True, size
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools