Hi Alex,
Sure, but let me first explain what I wanted to achieve. I wanted to
execute 2 QEMUs including independent TPMs. Currently I'm using swtpm
with socket path based on datime.
> SWTPM_DIR = "/tmp/qemu-swtpm-${DATETIME}"
> BB_BASEHASH_IGNORE_VARS:append = " SWTPM_DIR"
> SWTPM_SOCKET = "${SWTPM_DIR}/swtpm.sock"
> SWTPM_LOG = "${SWTPM_DIR}/swtpm.log"
> SWTPM_PID_FILE = "${SWTPM_DIR}/swtpm.pid"
>
> QB_SETUP_CMD = "\
> set -e; \
> export PATH="${STAGING_BINDIR_NATIVE}:${PATH}"; \
> swtpm --version; \
> mkdir -p ${SWTPM_DIR}; \
> swtpm_setup \
> --tpm2 \
> --reconfigure \
> --tpmstate ${SWTPM_DIR} \
> ...
This was ok for one QEMU. But now as I wanted to run a second instance,
it failed (which is obvious) doe to re-used path. So I wanted to have
something "unique" without braking the backport compatibility. So I
introduced the '@INSTANCE_ID@' with the same content, the datetime. The
qemubootconf then should have an entry like: qb_setup_cmd = set -e;
export PATH="/home/zuzana/...build/tmp/hosttools"; swtpm --version;
mkdir -p /tmp/qemu-swtpm-INSTANCE_ID@; swtpm_setup --tpm2 --reconfigure
--tpmstate /tmp/qemu-swtpm-@INSTANCE_ID@
Once runqemu is executed, the '@INSTANCE_ID@' is replaced by timestamp.
At the end I wanted to have qemuboot stable without additional
regeneration.
Do you see some better approach how to achieve it? :)
BR,
Zuzana
On Mon, 2026-06-08 at 08:09 +0200, Alexander Kanavin wrote:
> Can you please provide an example of how this is used, and what
> benefit it brings? "Would be nice" is a bit too vague as a
> justification.
>
> Alex
>
> On Sun, 7 Jun 2026 at 19:40, Zuzana via lists.openembedded.org
> <[email protected]> wrote:
> >
> > In some cases like running multiple QEMUs, would be nice to have an
> > option
> > to distinguish between them. For this reason I introduce an unique
> > instance
> > ID based on time. Later in cmd, the '@INSTANCE_ID@' could be used
> > for QEMU
> > identification.
> >
> > Signed-off-by: Zuzana Valekova Spitalova
> > <[email protected]>
> > ---
> > scripts/runqemu | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/runqemu b/scripts/runqemu
> > index 2c126e7f54..2de69dcd7c 100755
> > --- a/scripts/runqemu
> > +++ b/scripts/runqemu
> > @@ -227,6 +227,7 @@ class BaseConfig(object):
> > self.qmp = None
> > self.guest_agent = False
> > self.guest_agent_sockpath = '/tmp/qga.sock'
> > + self.instance_id = None
> >
> > def acquire_taplock(self, error=True):
> > logger.debug("Acquiring lockfile %s..." % self.taplock)
> > @@ -1111,8 +1112,11 @@ to your build configuration.
> > self.nfs_running = True
> >
> > def setup_cmd(self):
> > + self.instance_id = str(int(time.time()))
> > +
> > cmd = self.get('QB_SETUP_CMD')
> > if cmd != '':
> > + cmd = cmd.replace('@INSTANCE_ID@', self.instance_id)
> > logger.info('Running setup command %s' % str(cmd))
> > if subprocess.call(cmd, shell=True) != 0:
> > raise RunQemuError('Failed to run %s' % str(cmd))
> > @@ -1623,6 +1627,8 @@ to your build configuration.
> > if self.bios:
> > self.qemu_opt += " -bios %s" % self.bios
> >
> > + self.qemu_opt = self.qemu_opt.replace("@INSTANCE_ID@",
> > self.instance_id)
> > +
> > cmd = "%s %s" % (self.qemu_opt, kernel_opts)
> > cmds = shlex.split(cmd)
> > logger.info('Running %s\n' % cmd)
> > @@ -1647,6 +1653,7 @@ to your build configuration.
> > def cleanup_cmd(self):
> > cmd = self.get('QB_CLEANUP_CMD')
> > if cmd != '':
> > + cmd = cmd.replace('@INSTANCE_ID@', self.instance_id)
> > logger.info('Running cleanup command %s' % str(cmd))
> > if subprocess.call(cmd, shell=True) != 0:
> > raise RunQemuError('Failed to run %s' % str(cmd))
> > --
> > 2.43.0
> >
> >
> >
> >
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#238228):
https://lists.openembedded.org/g/openembedded-core/message/238228
Mute This Topic: https://lists.openembedded.org/mt/119693437/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-