** Description changed:

+ [ Impact ]
+ 
+  * Using qemu-system-x86 1:6.2+dfsg-2ubuntu6.24, the size of
+ /dev/nvme0n1 in a VM looks too big (like an integer overflow):
+ 
+ % qemu-img info nvme.img
+ image: nvme.img
+ file format: raw
+ virtual size: 1 TiB (1099511627776 bytes)
+ disk size: 1 MiB
+ 
+ ubuntu@ubuntu:~$ cat /proc/partitions
+ major minor  #blocks  name
+ 
+    8        0  209715200 sda
+    8        1  208552943 sda1
+    8       13    1047552 sda13
+    8       14       4096 sda14
+    8       15     108544 sda15
+   11        0        366 sr0
+    2        0          4 fd0
+  259        0 9223372035781033984 nvme0n1
+ 
+  * Testing this on Ubuntu Noble (24.04) which has QEMU 8.2 does not show
+ this issue. So only Jammy is affected.
+ 
+  * It is fixed by using a bigger "int64_t" datatype to store the size.
+ 
+ [ Test Plan ]
+ 
+ 1) qemu-img create -f raw nvme.img 1024G
+ 2) wget 
https://cloud-images.ubuntu.com/minimal/daily/plucky/current/plucky-minimal-cloudimg-amd64.img
+ 3) qemu-img create -f qcow2 -F qcow2 -b plucky-minimal-cloudimg-amd64.img 
plucky.img 20G
+ 4) cat > user-data <<EOF
+ #cloud-config
+ password: passw0rd
+ chpasswd: { expire: False }
+ ssh_pwauth: True
+ EOF
+ 5) cat > meta-data <<EOF
+ instance-id: 2b8a0076-bdf6-4ddb-a941-d4ebd652ce54
+ EOF
+ 6) cloud-localds plucky-nvme-cidata.iso user-data meta-data
+ 7) qemu-system-x86_64 -name plucky-nvme -smp 2 -m 2048 --enable-kvm -drive 
id=disk0,if=none,format=qcow2,file=plucky.img -drive 
id=cdrom0,if=none,media=cdrom,file=plucky-nvme-cidata.iso -device 
ide-hd,id=idedrv0,drive=disk0 -device ide-cd,id=idedrv1,drive=cdrom0 -drive 
id=nvme0,if=none,format=raw,file=nvme.img -device 
nvme,id=nvmedev0,drive=nvme0,serial=nvme123456 -net user,hostfwd=tcp::22222-:22 
-net nic,model=virtio -nographic -object 
rng-random,filename=/dev/urandom,id=rng0 -serial mon:stdio
+ 8) login as ubuntu
+ 9) cat /proc/partitions
+ 
+ [ Where problems could occur ]
+ 
+  * Think about what the upload changes in the software. Imagine the
+    change is wrong or breaks something else: how would this show up?
+ 
+  * It is assumed that any SRU candidate patch is well-tested before
+    upload and has a low overall risk of regression, but it's important
+    to make the effort to think about what ''could'' happen in the event
+    of a regression.
+ 
+  * This must never be "None" or "Low", or entirely an argument as to why
+    your upload is low risk.
+ 
+  * This both shows the SRU team that the risks have been considered,
+    and provides guidance to testers in regression-testing the SRU.
+ 
+ [ Other Info ]
+ 
+  * Upstream fix: https://gitlab.com/qemu-
+ project/qemu/-/commit/1e64facc015e16d8e4efa239feaeda9e4e9aeb04
+ 
+  * For any size of NVME disk <1TiB (even 1K less) the size is reported
+ correctly. Switching to ide, scsi or virtio device also fixes the disk
+ size reporting in guest.
+ 
+ 
+ --- original bug report ---
+ 
  1)
  % lsb_release -rd
  Description:    Ubuntu 22.04.5 LTS
  Release:        22.04
  
- 2) 
+ 2)
  % apt-cache policy qemu-system-x86
  qemu-system-x86:
-   Installed: 1:6.2+dfsg-2ubuntu6.24
-   Candidate: 1:6.2+dfsg-2ubuntu6.24
-   Version table:
-  *** 1:6.2+dfsg-2ubuntu6.24 500
-         500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 
Packages
-         500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
-         100 /var/lib/dpkg/status
-      1:6.2+dfsg-2ubuntu6 500
-         500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
+   Installed: 1:6.2+dfsg-2ubuntu6.24
+   Candidate: 1:6.2+dfsg-2ubuntu6.24
+   Version table:
+  *** 1:6.2+dfsg-2ubuntu6.24 500
+         500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 
Packages
+         500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
+         100 /var/lib/dpkg/status
+      1:6.2+dfsg-2ubuntu6 500
+         500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  
  3) size of /dev/nvme0n1 in VM matches virtual size of raw image file on
  host 1024G (1 TiB)
- 
  
  4) size of /dev/nvme0n1 size in VM looks too big, like an integer
  overflow
  
  % qemu-img info nvme.img
  image: nvme.img
  file format: raw
  virtual size: 1 TiB (1099511627776 bytes)
  disk size: 1 MiB
  
  ubuntu@ubuntu:~$ cat /proc/partitions
  major minor  #blocks  name
  
-    8        0  209715200 sda
-    8        1  208552943 sda1
-    8       13    1047552 sda13
-    8       14       4096 sda14
-    8       15     108544 sda15
-   11        0        366 sr0
-    2        0          4 fd0
-  259        0 9223372035781033984 nvme0n1
- 
+    8        0  209715200 sda
+    8        1  208552943 sda1
+    8       13    1047552 sda13
+    8       14       4096 sda14
+    8       15     108544 sda15
+   11        0        366 sr0
+    2        0          4 fd0
+  259        0 9223372035781033984 nvme0n1
  
  --
  testing this out on Ubuntu Noble (24.04) which has qemu 8.2 does not show 
this issue.
  
  It would be nice to get a backport of whatever fix went into 8.2 into
  6.2
  
- 
  Here's a simple reproducer:
- 
  
  1) qemu-img create -f raw nvme.img 1024G
  2) wget 
https://cloud-images.ubuntu.com/minimal/daily/plucky/current/plucky-minimal-cloudimg-amd64.img
  3) qemu-img create -f qcow2 -F qcow2 -b plucky-minimal-cloudimg-amd64.img 
plucky.img 20G
  4) cat > user-data <<EOF
  #cloud-config
  password: passw0rd
  chpasswd: { expire: False }
  ssh_pwauth: True
  EOF
  5) cat > meta-data <<EOF
  instance-id: 2b8a0076-bdf6-4ddb-a941-d4ebd652ce54
  EOF
  6) cloud-localds plucky-nvme-cidata.iso user-data meta-data
  7) qemu-system-x86_64 -name plucky-nvme -smp 2 -m 2048 --enable-kvm -drive 
id=disk0,if=none,format=qcow2,file=plucky.img -drive 
id=cdrom0,if=none,media=cdrom,file=plucky-nvme-cidata.iso -device 
ide-hd,id=idedrv0,drive=disk0 -device ide-cd,id=idedrv1,drive=cdrom0 -drive 
id=nvme0,if=none,format=raw,file=nvme.img -device 
nvme,id=nvmedev0,drive=nvme0,serial=nvme123456 -net user,hostfwd=tcp::22222-:22 
-net nic,model=virtio -nographic -object 
rng-random,filename=/dev/urandom,id=rng0 -serial mon:stdio
  8) login as ubuntu
  9) cat /proc/partitions
  
  For any size of NVME disk <1TiB (even 1K less) the size is reported
  correctly.  Switching to ide, scsi or virtio device also fixes the disk
  size reporting in guest.
  
  ProblemType: Bug
  DistroRelease: Ubuntu 22.04
  Package: qemu-system-x86 1:6.2+dfsg-2ubuntu6.24
  ProcVersionSignature: Ubuntu 6.8.0-52.53~22.04.1-generic 6.8.12
  Uname: Linux 6.8.0-52-generic x86_64
  NonfreeKernelModules: zfs
  ApportVersion: 2.20.11-0ubuntu82.6
  Architecture: amd64
  CasperMD5CheckResult: unknown
  Date: Wed Feb 19 14:31:35 2025
  MachineType: ASUS System Product Name
  ProcEnviron:
-  LC_TIME=en_GB.UTF-8
-  TERM=screen-256color-bce
-  PATH=(custom, no user)
-  LANG=en_US.UTF-8
-  SHELL=/bin/bash
+  LC_TIME=en_GB.UTF-8
+  TERM=screen-256color-bce
+  PATH=(custom, no user)
+  LANG=en_US.UTF-8
+  SHELL=/bin/bash
  ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-6.8.0-52-generic 
root=UUID=69898701-f49d-4942-87a5-85b4e512e4f4 ro default_hugepagesz=1GB 
hugepagesz=1G hugepages=12 kvm_amd.sev=1 mitigations=off
  SourcePackage: qemu
  UpgradeStatus: Upgraded to jammy on 2024-05-18 (277 days ago)
  dmi.bios.date: 07/13/2021
  dmi.bios.release: 15.2
  dmi.bios.vendor: American Megatrends Inc.
  dmi.bios.version: 1502
  dmi.board.asset.tag: Default string
  dmi.board.name: PRIME TRX40-PRO
  dmi.board.vendor: ASUSTeK COMPUTER INC.
  dmi.board.version: Rev 1.xx
  dmi.chassis.asset.tag: Default string
  dmi.chassis.type: 3
  dmi.chassis.vendor: Default string
  dmi.chassis.version: Default string
  dmi.modalias: 
dmi:bvnAmericanMegatrendsInc.:bvr1502:bd07/13/2021:br15.2:svnASUS:pnSystemProductName:pvrSystemVersion:rvnASUSTeKCOMPUTERINC.:rnPRIMETRX40-PRO:rvrRev1.xx:cvnDefaultstring:ct3:cvrDefaultstring:skuSKU:
  dmi.product.family: To be filled by O.E.M.
  dmi.product.name: System Product Name
  dmi.product.sku: SKU
  dmi.product.version: System Version
  dmi.sys.vendor: ASUS

** Description changed:

  [ Impact ]
  
-  * Using qemu-system-x86 1:6.2+dfsg-2ubuntu6.24, the size of
+  * Using qemu-system-x86 1:6.2+dfsg-2ubuntu6.24, the size of
  /dev/nvme0n1 in a VM looks too big (like an integer overflow):
  
  % qemu-img info nvme.img
  image: nvme.img
  file format: raw
  virtual size: 1 TiB (1099511627776 bytes)
  disk size: 1 MiB
  
  ubuntu@ubuntu:~$ cat /proc/partitions
  major minor  #blocks  name
  
     8        0  209715200 sda
     8        1  208552943 sda1
     8       13    1047552 sda13
     8       14       4096 sda14
     8       15     108544 sda15
    11        0        366 sr0
     2        0          4 fd0
   259        0 9223372035781033984 nvme0n1
  
-  * Testing this on Ubuntu Noble (24.04) which has QEMU 8.2 does not show
- this issue. So only Jammy is affected.
- 
-  * It is fixed by using a bigger "int64_t" datatype to store the size.
+  * It is fixed by using a bigger "int64_t" datatype to store the size.
  
  [ Test Plan ]
  
  1) qemu-img create -f raw nvme.img 1024G
  2) wget 
https://cloud-images.ubuntu.com/minimal/daily/plucky/current/plucky-minimal-cloudimg-amd64.img
  3) qemu-img create -f qcow2 -F qcow2 -b plucky-minimal-cloudimg-amd64.img 
plucky.img 20G
  4) cat > user-data <<EOF
  #cloud-config
  password: passw0rd
  chpasswd: { expire: False }
  ssh_pwauth: True
  EOF
  5) cat > meta-data <<EOF
  instance-id: 2b8a0076-bdf6-4ddb-a941-d4ebd652ce54
  EOF
  6) cloud-localds plucky-nvme-cidata.iso user-data meta-data
  7) qemu-system-x86_64 -name plucky-nvme -smp 2 -m 2048 --enable-kvm -drive 
id=disk0,if=none,format=qcow2,file=plucky.img -drive 
id=cdrom0,if=none,media=cdrom,file=plucky-nvme-cidata.iso -device 
ide-hd,id=idedrv0,drive=disk0 -device ide-cd,id=idedrv1,drive=cdrom0 -drive 
id=nvme0,if=none,format=raw,file=nvme.img -device 
nvme,id=nvmedev0,drive=nvme0,serial=nvme123456 -net user,hostfwd=tcp::22222-:22 
-net nic,model=virtio -nographic -object 
rng-random,filename=/dev/urandom,id=rng0 -serial mon:stdio
  8) login as ubuntu
  9) cat /proc/partitions
  
  [ Where problems could occur ]
  
-  * Think about what the upload changes in the software. Imagine the
-    change is wrong or breaks something else: how would this show up?
- 
-  * It is assumed that any SRU candidate patch is well-tested before
-    upload and has a low overall risk of regression, but it's important
-    to make the effort to think about what ''could'' happen in the event
-    of a regression.
- 
-  * This must never be "None" or "Low", or entirely an argument as to why
-    your upload is low risk.
- 
-  * This both shows the SRU team that the risks have been considered,
-    and provides guidance to testers in regression-testing the SRU.
+  * The patch modifies the NVME Namespace handling, especially size
+ calculation of emulated NVME devices. Should anything go wrong this
+ could affect the usage of emulated NVME disks.
  
  [ Other Info ]
  
-  * Upstream fix: https://gitlab.com/qemu-
+  * Upstream fix: https://gitlab.com/qemu-
  project/qemu/-/commit/1e64facc015e16d8e4efa239feaeda9e4e9aeb04
  
-  * For any size of NVME disk <1TiB (even 1K less) the size is reported
+  * Testing this on Ubuntu Noble (24.04) which has QEMU 8.2 does not show
+ this issue. So only Jammy is affected.
+ 
+  * For any size of NVME disk <1TiB (even 1K less) the size is reported
  correctly. Switching to ide, scsi or virtio device also fixes the disk
  size reporting in guest.
- 
  
  --- original bug report ---
  
  1)
  % lsb_release -rd
  Description:    Ubuntu 22.04.5 LTS
  Release:        22.04
  
  2)
  % apt-cache policy qemu-system-x86
  qemu-system-x86:
    Installed: 1:6.2+dfsg-2ubuntu6.24
    Candidate: 1:6.2+dfsg-2ubuntu6.24
    Version table:
   *** 1:6.2+dfsg-2ubuntu6.24 500
          500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 
Packages
          500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 
Packages
          100 /var/lib/dpkg/status
       1:6.2+dfsg-2ubuntu6 500
          500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
  
  3) size of /dev/nvme0n1 in VM matches virtual size of raw image file on
  host 1024G (1 TiB)
  
  4) size of /dev/nvme0n1 size in VM looks too big, like an integer
  overflow
  
  % qemu-img info nvme.img
  image: nvme.img
  file format: raw
  virtual size: 1 TiB (1099511627776 bytes)
  disk size: 1 MiB
  
  ubuntu@ubuntu:~$ cat /proc/partitions
  major minor  #blocks  name
  
     8        0  209715200 sda
     8        1  208552943 sda1
     8       13    1047552 sda13
     8       14       4096 sda14
     8       15     108544 sda15
    11        0        366 sr0
     2        0          4 fd0
   259        0 9223372035781033984 nvme0n1
  
  --
  testing this out on Ubuntu Noble (24.04) which has qemu 8.2 does not show 
this issue.
  
  It would be nice to get a backport of whatever fix went into 8.2 into
  6.2
  
  Here's a simple reproducer:
  
  1) qemu-img create -f raw nvme.img 1024G
  2) wget 
https://cloud-images.ubuntu.com/minimal/daily/plucky/current/plucky-minimal-cloudimg-amd64.img
  3) qemu-img create -f qcow2 -F qcow2 -b plucky-minimal-cloudimg-amd64.img 
plucky.img 20G
  4) cat > user-data <<EOF
  #cloud-config
  password: passw0rd
  chpasswd: { expire: False }
  ssh_pwauth: True
  EOF
  5) cat > meta-data <<EOF
  instance-id: 2b8a0076-bdf6-4ddb-a941-d4ebd652ce54
  EOF
  6) cloud-localds plucky-nvme-cidata.iso user-data meta-data
  7) qemu-system-x86_64 -name plucky-nvme -smp 2 -m 2048 --enable-kvm -drive 
id=disk0,if=none,format=qcow2,file=plucky.img -drive 
id=cdrom0,if=none,media=cdrom,file=plucky-nvme-cidata.iso -device 
ide-hd,id=idedrv0,drive=disk0 -device ide-cd,id=idedrv1,drive=cdrom0 -drive 
id=nvme0,if=none,format=raw,file=nvme.img -device 
nvme,id=nvmedev0,drive=nvme0,serial=nvme123456 -net user,hostfwd=tcp::22222-:22 
-net nic,model=virtio -nographic -object 
rng-random,filename=/dev/urandom,id=rng0 -serial mon:stdio
  8) login as ubuntu
  9) cat /proc/partitions
  
  For any size of NVME disk <1TiB (even 1K less) the size is reported
  correctly.  Switching to ide, scsi or virtio device also fixes the disk
  size reporting in guest.
  
  ProblemType: Bug
  DistroRelease: Ubuntu 22.04
  Package: qemu-system-x86 1:6.2+dfsg-2ubuntu6.24
  ProcVersionSignature: Ubuntu 6.8.0-52.53~22.04.1-generic 6.8.12
  Uname: Linux 6.8.0-52-generic x86_64
  NonfreeKernelModules: zfs
  ApportVersion: 2.20.11-0ubuntu82.6
  Architecture: amd64
  CasperMD5CheckResult: unknown
  Date: Wed Feb 19 14:31:35 2025
  MachineType: ASUS System Product Name
  ProcEnviron:
   LC_TIME=en_GB.UTF-8
   TERM=screen-256color-bce
   PATH=(custom, no user)
   LANG=en_US.UTF-8
   SHELL=/bin/bash
  ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-6.8.0-52-generic 
root=UUID=69898701-f49d-4942-87a5-85b4e512e4f4 ro default_hugepagesz=1GB 
hugepagesz=1G hugepages=12 kvm_amd.sev=1 mitigations=off
  SourcePackage: qemu
  UpgradeStatus: Upgraded to jammy on 2024-05-18 (277 days ago)
  dmi.bios.date: 07/13/2021
  dmi.bios.release: 15.2
  dmi.bios.vendor: American Megatrends Inc.
  dmi.bios.version: 1502
  dmi.board.asset.tag: Default string
  dmi.board.name: PRIME TRX40-PRO
  dmi.board.vendor: ASUSTeK COMPUTER INC.
  dmi.board.version: Rev 1.xx
  dmi.chassis.asset.tag: Default string
  dmi.chassis.type: 3
  dmi.chassis.vendor: Default string
  dmi.chassis.version: Default string
  dmi.modalias: 
dmi:bvnAmericanMegatrendsInc.:bvr1502:bd07/13/2021:br15.2:svnASUS:pnSystemProductName:pvrSystemVersion:rvnASUSTeKCOMPUTERINC.:rnPRIMETRX40-PRO:rvrRev1.xx:cvnDefaultstring:ct3:cvrDefaultstring:skuSKU:
  dmi.product.family: To be filled by O.E.M.
  dmi.product.name: System Product Name
  dmi.product.sku: SKU
  dmi.product.version: System Version
  dmi.sys.vendor: ASUS

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2098896

Title:
  nvme disks 1TiB or greater show incorrect size

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/2098896/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to