← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] lp:~daniel-thewatkins/cloud-init/lp1460715 into lp:cloud-init

 

I'd like to read /sys if we can.  blockdev is fine, but that costs us 2 subprocesses for information that we could conceivably read.

one last comment i should have added for reference later was that an example qemu command line where we provide all the sizes is like:
 
qemu-system-x86_64 -enable-kvm -drive file=/tmp/tmp.uCSmIFVSuA/disk.img,if=none,id=disk_img_1,format=qcow2 -device virtio-blk-pci,bootindex=1,scsi=off,drive=disk_img_1,id=virtio-disk-1, -drive file=/tmp/tmp.uCSmIFVSuA/extra.img,if=none,id=disk_img_2,format=raw -device virtio-blk-pci,bootindex=2,scsi=off,drive=disk_img_2,id=virtio-disk-2,physical_block_size=4096,logical_block_size=4096,min_io_size=4096,opt_io_size=4096, -device virtio-net-pci,netdev=net00 -netdev type=user,id=net00 -m 768 -echr 0x05 -nographic

Diff comments:

> === modified file 'cloudinit/config/cc_disk_setup.py'
> --- cloudinit/config/cc_disk_setup.py	2015-07-22 19:14:33 +0000
> +++ cloudinit/config/cc_disk_setup.py	2015-10-20 09:28:10 +0000
> @@ -343,14 +344,13 @@
>  
>  
>  def get_mbr_hdd_size(device):
> -    size_cmd = [SFDISK_CMD, '--show-size', device]
> -    size = None
>      try:
> -        size, _err = util.subp(size_cmd)
> +        size_in_bytes, _ = util.subp([BLKDEV_CMD, '--getsize64', device])
> +        sector_size, _ = util.subp([BLKDEV_CMD, '--getss', device])
>      except Exception as e:
>          raise Exception("Failed to get %s size\n%s" % (device, e))
>  
> -    return int(size.strip())

so, its probably not your fault, but 'get_mbr_hdd_size(device)' returns the size in sectors of a variable size.  Thats kind of confusing.  Maybe it shoudl return size in bytes *and* sector size ?

additionally, 'get_mbr_hdd_size'... why would the mbr size be different from the gpt size.  that seems odd too. And again, i realize you didn't write this code originally, and i should have thought about such things then.

> +    return int(size_in_bytes) / int(sector_size)
>  
>  
>  def get_gpt_hdd_size(device):


-- 
https://code.launchpad.net/~daniel-thewatkins/cloud-init/lp1460715/+merge/274897
Your team cloud init development team is requested to review the proposed merge of lp:~daniel-thewatkins/cloud-init/lp1460715 into lp:cloud-init.


References