Skip to content

run_qemu.sh: replace -drive rootfs with -blockdev + -device #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Jun 10, 2025

According to Itaru Kitayama in #210, this fixes the following error:

  qemu-system-aarch64: -drive file=root.img,format=raw,media=disk: PCI:
    Only PCI/PCIe bridges can be plugged into pxb-cxl

Jonathan explains this is due to on arm64 -drive is virtoi-blk by
default and we need to set a bus via the -device option. Do it as
Jonathan suggested in:

https://lore.kernel.org/linux-cxl/20250520183109.00002730@huawei.com/

From https://www.qemu.org/docs/master/system/qemu-manpage.html#hxtool-1

The QEMU block device handling options have a long history and have gone
through several iterations as the feature set and complexity of the
block layer have grown. Many online guides to QEMU often reference older
and deprecated options, which can lead to confusion.

The most explicit way to describe disks is to use a combination of
-device to specify the hardware device and -blockdev to describe the
backend. The device defines what the guest sees and the backend
describes how QEMU handles the data. It is the only guaranteed stable
interface for describing block devices and as such is recommended for
management tools and scripting.

The -drive option combines the device and backend into a single command
line option which is a more human friendly. There is however no
interface stability guarantee although some older board models still
need updating to work with the modern blockdev forms.

Co-developed-by: Jonathan Cameron Jonathan.Cameron@huawei.com
Co-developed-by: Itaru Kitayama itaru.kitayama@fujitsu.com
Tested-by: Itaru Kitayama itaru.kitayama@fujitsu.com
Signed-off-by: Marc Herbert marc.herbert@intel.com

According to Itaru Kitayama in pmem#210, this fixes the following error:

```
  qemu-system-aarch64: -drive file=root.img,format=raw,media=disk: PCI:
    Only PCI/PCIe bridges can be plugged into pxb-cxl
```

> Jonathan explains this is due to on arm64 -drive is virtoi-blk by
> default and we need to set a bus via the -device option. Do it as
> Jonathan suggested in:
>
> https://lore.kernel.org/linux-cxl/20250520183109.00002730@huawei.com/

From https://www.qemu.org/docs/master/system/qemu-manpage.html#hxtool-1

  The QEMU block device handling options have a long history and have gone
  through several iterations as the feature set and complexity of the
  block layer have grown. Many online guides to QEMU often reference older
  and deprecated options, which can lead to confusion.

  The most explicit way to describe disks is to use a combination of
  -device to specify the hardware device and -blockdev to describe the
  backend. The device defines what the guest sees and the backend
  describes how QEMU handles the data. It is the only guaranteed stable
  interface for describing block devices and as such is recommended for
  management tools and scripting.

  The -drive option combines the device and backend into a single command
  line option which is a more human friendly. There is however no
  interface stability guarantee although some older board models still
  need updating to work with the modern blockdev forms.

Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Co-developed-by: Itaru Kitayama <itaru.kitayama@fujitsu.com>
Tested-by: Itaru Kitayama <itaru.kitayama@fujitsu.com>
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb marc-hb marked this pull request as ready for review June 11, 2025 00:07
@marc-hb

This comment was marked as resolved.

@marc-hb

This comment was marked as resolved.

@ikitayama
Copy link
Collaborator

@marc-hb thanks for this new PR. I've tested your proposed branch and I was able to get to the prompt (autologin) after commenting some Debian testing packages out from the list as the mkosi doesn't know how to expand the rootfs image as the number of packages grow.

I tested mkosi alone and tried to grow disk sizes, and with the recent mkosi, I think we need two .conf files:
10-root.conf and 20-esp.conf under the mkosi.repart directory.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Jun 11, 2025

@ikitayama I really don't understand how this PR can be related to Debian packages and disk sizes, is it? I mean, does this PR make any difference with respect to building the image? It really should not.

BTW every time I have a "disk full" message, -r wipe solves the problem for me. I don't really understand why but it does. Again: unrelated to this PR.

@ikitayama
Copy link
Collaborator

@marc-hb the wipe option -r wipe did not work in my set up that's why I reported here. It should not be a blocker to this PR.

@marc-hb marc-hb merged commit dfa1d3f into pmem:main Jun 11, 2025
4 checks passed
@marc-hb marc-hb deleted the qemu-no-drive branch June 11, 2025 21:40
@marc-hb
Copy link
Collaborator Author

marc-hb commented Jun 11, 2025

the wipe option -r wipe did not work in my set up that's why I reported here.

You can also try rm -rf linux/qbuild/. Or, a different mkosi version?

@ikitayama
Copy link
Collaborator

I updated mkosi repository chcked out from GitHub and did not hit the mkosi image creation thanks.

At the top of the run_qemu.sh script:

[...]
shopt -s inherit_errexit

# default config
: "${builddir:=./qbuild}"
rootpw="root"
rootfssize="10G"
[...]

Is ths rootfssize shell variable honored during the execution? In my trial the image size of root.img.raw file is 2.4G.

marc-hb added a commit to marc-hb/run_qemu that referenced this pull request Jun 11, 2025
As discovered in (unrelated) pmem#211

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb
Copy link
Collaborator Author

marc-hb commented Jun 11, 2025

Is ths rootfssize shell variable honored during the execution?

It depends:

marc-hb added a commit that referenced this pull request Jun 11, 2025
As discovered in (unrelated) #211

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
@marc-hb
Copy link
Collaborator Author

marc-hb commented Jun 12, 2025

I just realized QEMU silently ignores -snapshot now! Stay tuned...

      -snapshot
              Write to temporary files instead of disk image files. In this case, the raw disk image you use is not written back.
              You can however force the write back by pressing C-a s (see the Disk Images chapter in the System  Emulation  Users Guide).

              WARNING:
                 snapshot  is incompatible with -blockdev (instead use qemu-img to manually cre‐
                 ate snapshot images to attach to your blockdev).  If you have  mixed  -blockdev
                 and  -drive declarations you can use the 'snapshot' property on your drive dec‐
                 larations instead of this global option.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Jun 12, 2025

I just realized QEMU silently ignores -snapshot now! Stay tuned...

Tentative fix in #213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants