Skip to contentSkip to conversation

Fix qemu could not boot windows vm which converted from phy-partition

PATCH In review DuanZhenzhong 2 participants 2 messages Aug 5, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix qemu could not boot windows vm which converted from phy-partition

Hi,

When booting up windows VM which converted by dd windows physical partition,
it failed with "Error Loading Operating System", the partition build on scsi/raid controller. The root cause is qemu and hvmloader could not calaulated C/H/S correctly, then ntloader could not found the root partition.

qemu-xen.git/block.c +6 -1
diff -urNp xen-3.4.0/qemu-xen.git/block.c xen-3.4.0_lba/qemu-xen.git/block.c
@@ -884,7 +884,12 @@ void bdrv_guess_geometry(BlockDriverStat
         *psecs = secs;
     } else {
         if (guess_disk_lchs(bs, &cylinders, &heads, &secs) == 0) {
-            if (heads > 16) {
+            if(secs==32){
+                *pcyls = cylinders;
+                *pheads = heads;
+                *psecs = secs;
+                 bdrv_set_translation_hint(bs, BIOS_ATA_TRANSLATION_LBA);
+            } else if (heads > 16) {
                 /* if heads > 16, it means that a BIOS LBA
                    translation was active, so the default
                    hardware geometry is OK */
tools/firmware/rombios/rombios.c +5 -3
diff -urNp xen-3.4.0/tools/firmware/rombios/rombios.c xen-3.4.0_lba/tools/firmware/rombios/rombios.c
@@ -2740,8 +2740,7 @@ void ata_detect( )
         case ATA_TRANSLATION_NONE:
           break;
         case ATA_TRANSLATION_LBA:
-          spt = 63;
-          sectors_low /= 63;
+          sectors_low /= spt;
           heads = sectors_low / 1024;
           if (heads>128) heads = 255;
           else if (heads>64) heads = 128;
@@ -5442,6 +5441,7 @@ int13_harddisk(EHAX, DS, ES, DI, SI, BP,
   Bit16u npc, nph, npspt, nlc, nlh, nlspt;
   Bit16u size, count;
   Bit8u  device, status;
+  Bit8u  translation;
 
   BX_DEBUG_INT13_HD("int13_harddisk: AX=%04x BX=%04x CX=%04x DX=%04x ES=%04x\n", AX, BX, CX, DX, ES);
 
@@ -5512,8 +5512,10 @@ int13_harddisk(EHAX, DS, ES, DI, SI, BP,
       nph   = read_word(ebda_seg, &EbdaData->ata.devices[device].pchs.heads);
       npspt = read_word(ebda_seg, &EbdaData->ata.devices[device].pchs.spt);
 
+	translation = read_byte(ebda_seg,&EbdaData->ata.devices[device].translation);
+
       // if needed, translate lchs to lba, and execute command
-      if ( (nph != nlh) || (npspt != nlspt)) {
+      if ( (nph != nlh) || (npspt != nlspt) || (translation == (ATA_TRANSLATION_LBA))) {
         lba_low = ((((Bit32u)cylinder * (Bit32u)nlh) + (Bit32u)head) * (Bit32u)nlspt) + (Bit32u)sector - 1;
         lba_high = 0;
         sector = 0; // this forces the command to be lba

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

This will need splitting into qemu and hvmloader separate patches, since the qemu component belongs in the qemu-xen-unstable git repository. Please also indicate which order the two patches should then be applied in (if it matters). It would also be useful to know precisely what the fix does, rather than merely what it fixes (although that is very useful in a changeset comment too, of course).

Thanks,
Keir

Quoted 11 lines · DuanZhenzhong

Hi,

When booting up windows VM which converted by dd windows physical partition,
it failed with "Error Loading Operating System", the partition build on scsi/raid controller. The root cause is qemu and hvmloader could not calaulated C/H/S correctly, then ntloader could not found the root partition.