[pve-devel] [PATCH] add ide-cd, ide-hd, scsi-cd, scsi-hd, scsi-block to device syntax

Dietmar Maurer dietmar at proxmox.com
Wed Dec 7 06:28:37 CET 2011


Hi Alexandre,

Do we really need the 'media=block' option?

I think that it is easy to detect a block device, so we can automatically use 'scsi-block' in that case?

Or are there disadvantages?


> -----Original Message-----
> From: pve-devel-bounces at pve.proxmox.com [mailto:pve-devel-
> bounces at pve.proxmox.com] On Behalf Of Derumier Alexandre
> Sent: Dienstag, 06. Dezember 2011 09:52
> To: pve-devel at pve.proxmox.com
> Subject: [pve-devel] [PATCH] add ide-cd, ide-hd, scsi-cd, scsi-hd, scsi-block to
> device syntax
> 
> ide-cd, ide-hd replace old ide-drive legacy syntax
> scsi-cd, iscsi-hd replace old ide-drive legacy syntax
> scsi-block is new in qemu 1.0
> 
> Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
> ---
>  PVE/QemuServer.pm |   22 ++++++++++++++++++----
>  1 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 858b292..d42463d 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -445,7 +445,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-
> ide", $idedesc);
>  my $scsidesc = {
>      optional => 1,
>      type => 'string', format => 'pve-qm-drive',
> -    typetext => '[volume=]volume,] [,media=cdrom|disk]
> [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off]
> [,cache=none|writethrough|writeback|unsafe] [,format=f] [,backup=yes|no]
> [,aio=native|threads]',
> +    typetext => '[volume=]volume,] [,media=cdrom|disk|block]
> [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off]
> [,cache=none|writethrough|writeback|unsafe] [,format=f] [,backup=yes|no]
> [,aio=native|threads]',
>      description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to 13).",
>  };
>  PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
> @@ -872,6 +872,8 @@ sub print_drivedevice_full {
>      my $device = '';
>      my $maxdev = 0;
> 
> +
> +
>      if ($drive->{interface} eq 'virtio') {
>        my $pciaddr = print_pci_addr("$drive->{interface}$drive->{index}");
>        $device = "virtio-blk-pci,drive=drive-$drive->{interface}$drive-
> >{index},id=$drive->{interface}$drive->{index}$pciaddr";
> @@ -882,8 +884,19 @@ sub print_drivedevice_full {
>        $maxdev = 7;
>        my $controller = int($drive->{index} / $maxdev);
>        my $unit = $drive->{index} % $maxdev;
> +      my $devicetype = '';
> +
> +      if($drive->{media} && $drive->{media} eq 'cdrom') {
> +     	$devicetype = "cd";
> +      }
> +      elsif ($drive->{media} && $drive->{media} eq 'block') {
> +	$devicetype = $drive->{media};
> +      }
> +      else {
> +	$devicetype = "hd";
> +      }
> 
> -      $device = "scsi-disk,bus=scsi$controller.0,scsi-id=$unit,drive=drive-$drive-
> >{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
> +      $device = "scsi-$devicetype,bus=scsi$controller.0,scsi-id=$unit,drive=drive-
> $drive->{interface}$drive->{index},id=device-$drive->{interface}$drive-
> >{index}";
>      }
> 
>      elsif ($drive->{interface} eq 'ide'){
> @@ -891,8 +904,9 @@ sub print_drivedevice_full {
>        $maxdev = 2;
>        my $controller = int($drive->{index} / $maxdev);
>        my $unit = $drive->{index} % $maxdev;
> +      my $devicetype = ($drive->{media} && $drive->{media} eq 'cdrom') ? "cd" :
> "hd";
> 
> -      $device = "ide-drive,bus=ide.$controller,unit=$unit,drive=drive-$drive-
> >{interface}$drive->{index},id=device-$drive->{interface}$drive->{index}";
> +      $device = "ide-$devicetype,bus=ide.$controller,unit=$unit,drive=drive-
> $drive->{interface}$drive->{index},id=device-$drive->{interface}$drive-
> >{index}";
>      }
> 
>      if ($drive->{interface} eq 'usb'){
> --
> 1.7.2.5
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list