[libvirt] [TCK PATCH] block devices: allow specification of size for safety

Jim Meyering jim at meyering.net
Wed May 5 19:31:37 UTC 2010


Dave Allan wrote:
> On Wed, May 05, 2010 at 08:54:35PM +0200, Jim Meyering wrote:
>> Eric Blake wrote:
>> > I was getting failures of domain/103-blockdev-save-restore.t when
>> > connecting as qemu:///session, since my uid could stat /dev/sdb
>> > but not open it.  That test now skips for unprivileged users, as well
>> > as adds a layer of sanity checking against expected size to avoid
>> > trashing the wrong device.
>
> Can we provide the option to specify the device serial number so that
> it's really impossible to trash the wrong device?

Given that this is a good idea, next question is obviously
how to get the serial number.  One way seems to be via hdparm,
e.g., hdparm -i /dev/sda

    /dev/sda:

     Model=ST3320620AS, FwRev=3.AAK, SerialNo=9QF6ET0H
     Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
     RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
     BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=off
     CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=625142448
     IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
     PIO modes:  pio0 pio1 pio2 pio3 pio4
     DMA modes:  mdma0 mdma1 mdma2
     UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6
     AdvancedPM=no WriteCache=enabled
     Drive conforms to: Unspecified:  ATA/ATAPI-1,2,3,4,5,6,7

     * signifies the current active mode

which reminds me that some devices have a serial number of all zeros,
so maybe to be truly bullet-proof you'd want all three from that
first line: Model, FwRev, SerialNo




More information about the libvir-list mailing list