qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] hw/uefi: add pcap support
Date: Thu, 27 Nov 2025 06:48:40 +0100	[thread overview]
Message-ID: <084f637e-701a-4b46-a3b2-f4755ddb40fb@linaro.org> (raw)
In-Reply-To: <20251126142559.4081483-3-kraxel@redhat.com>

On 26/11/25 15:25, Gerd Hoffmann wrote:
> Add pcapfile property to uevi-vars-* devices, allowing to write out a
> capture of the communication traffic between uefi firmware and qemu.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   include/hw/uefi/var-service.h | 10 ++++
>   hw/uefi/var-service-core.c    |  7 +++
>   hw/uefi/var-service-pcap.c    | 94 +++++++++++++++++++++++++++++++++++
>   hw/uefi/var-service-sysbus.c  |  1 +
>   hw/uefi/meson.build           |  1 +
>   roms/edk2                     |  2 +-
>   6 files changed, 114 insertions(+), 1 deletion(-)
>   create mode 100644 hw/uefi/var-service-pcap.c


> diff --git a/hw/uefi/var-service-pcap.c b/hw/uefi/var-service-pcap.c
> new file mode 100644
> index 000000000000..879eee4699a3
> --- /dev/null
> +++ b/hw/uefi/var-service-pcap.c
> @@ -0,0 +1,94 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +#include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> +#include "qemu/pcap.h"
> +#include "system/dma.h"
> +
> +#include "hw/uefi/var-service.h"
> +
> +#define LINKTYPE_EDK2_MM  302
> +
> +#define SNAPLEN   (64 * 1024)
> +#define TYPE_RESET       0x01
> +#define TYPE_REQUEST     0x02
> +#define TYPE_REPLY       0x03
> +
> +static void uefi_vars_pcap_header(FILE *fp)
> +{

static const

> +    struct pcap_hdr header = {
> +        .magic_number  = PCAP_MAGIC,
> +        .version_major = PCAP_MAJOR,
> +        .version_minor = PCAP_MINOR,
> +        .snaplen       = SNAPLEN,
> +        .network       = LINKTYPE_EDK2_MM,
> +    };
> +
> +    fwrite(&header, sizeof(header), 1, fp);
> +    fflush(fp);
> +}


> +void uefi_vars_pcap_init(uefi_vars_state *uv)
> +{
> +    int fd;
> +
> +    if (!uv->pcapfile) {
> +        return;
> +    }
> +
> +    fd = qemu_open_old(uv->pcapfile,
> +                       O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0666);

Consider qemu_create() to help Markus' tree-wide cleanup.

> +    if (fd < 0) {
> +        warn_report("open %s: %s", uv->pcapfile, strerror(errno));
> +        return;
> +    }
> +
> +    uv->pcapfp = fdopen(fd, "wb");
> +    uefi_vars_pcap_header(uv->pcapfp);
> +}


> diff --git a/roms/edk2 b/roms/edk2
> index 4dfdca63a934..46548b1adac8 160000
> --- a/roms/edk2
> +++ b/roms/edk2
> @@ -1 +1 @@
> -Subproject commit 4dfdca63a93497203f197ec98ba20e2327e4afe4
> +Subproject commit 46548b1adac82211d8d11da12dd914f41e7aa775

Unrelated change I presume.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



      reply	other threads:[~2025-11-27  5:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 14:25 [PATCH 0/2] hw/uefi: add pcap support Gerd Hoffmann
2025-11-26 14:25 ` [PATCH 1/2] move pcap structs to header file Gerd Hoffmann
2025-11-27  5:44   ` Philippe Mathieu-Daudé
2025-11-26 14:25 ` [PATCH 2/2] hw/uefi: add pcap support Gerd Hoffmann
2025-11-27  5:48   ` Philippe Mathieu-Daudé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=084f637e-701a-4b46-a3b2-f4755ddb40fb@linaro.org \
    --to=philmd@linaro.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).