Revision cd461c8445392d02c268d79f7ed68387b440c4b3 authored by lyx634449800 on 08 April 2024, 02:00:03 UTC, committed by Michael Tokarev on 09 April 2024, 17:42:59 UTC
The set_config callback function vhost_vdpa_device_get_config in
vdpa-dev does not fetch the current device status from the hardware
device, causing the guest os to not receive the latest device status
information.

The hardware updates the config status of the vdpa device and then
notifies the os. The guest os receives an interrupt notification,
triggering a get_config access in the kernel, which then enters qemu
internally. Ultimately, the vhost_vdpa_device_get_config function of
vdpa-dev is called

One scenario encountered is when the device needs to bring down the
vdpa net device. After modifying the status field of virtio_net_config
in the hardware, it sends an interrupt notification. However, the guest
os always receives the STATUS field as VIRTIO_NET_S_LINK_UP.

Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20240408020003.1979-1-yuxue.liu@jaguarmicro.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 6ae72f609a21cfc56bf655cd4bcded5d07691ce7)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
1 parent b57b102
Raw File
qemu-edid.c
/*
 * QEMU EDID test tool.
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */
#include "qemu/osdep.h"
#include "qemu/bswap.h"
#include "qemu/cutils.h"
#include "hw/display/edid.h"

static qemu_edid_info info = {
    .prefx = 1280,
    .prefy = 800,
};

static void usage(FILE *out)
{
    fprintf(out,
            "\n"
            "This is a test tool for the qemu edid generator.\n"
            "\n"
            "Typically you'll pipe the output into edid-decode\n"
            "to check if the generator works correctly.\n"
            "\n"
            "usage: qemu-edid <options>\n"
            "options:\n"
            "    -h             print this text\n"
            "    -o <file>      set output file (stdout by default)\n"
            "    -v <vendor>    set monitor vendor (three letters)\n"
            "    -n <name>      set monitor name\n"
            "    -s <serial>    set monitor serial\n"
            "    -d <dpi>       set display resolution\n"
            "    -x <prefx>     set preferred width\n"
            "    -y <prefy>     set preferred height\n"
            "    -X <maxx>      set maximum width\n"
            "    -Y <maxy>      set maximum height\n"
            "\n");
}

int main(int argc, char *argv[])
{
    FILE *outfile = NULL;
    uint8_t blob[512];
    size_t size;
    uint32_t dpi = 100;
    int rc;

    for (;;) {
        rc = getopt(argc, argv, "ho:x:y:X:Y:d:v:n:s:");
        if (rc == -1) {
            break;
        }
        switch (rc) {
        case 'o':
            if (outfile) {
                fprintf(stderr, "outfile specified twice\n");
                exit(1);
            }
            outfile = fopen(optarg, "w");
            if (outfile == NULL) {
                fprintf(stderr, "open %s: %s\n", optarg, strerror(errno));
                exit(1);
            }
            break;
        case 'x':
            if (qemu_strtoui(optarg, NULL, 10, &info.prefx) < 0) {
                fprintf(stderr, "not a number: %s\n", optarg);
                exit(1);
            }
            break;
        case 'y':
            if (qemu_strtoui(optarg, NULL, 10, &info.prefy) < 0) {
                fprintf(stderr, "not a number: %s\n", optarg);
                exit(1);
            }
            break;
        case 'X':
            if (qemu_strtoui(optarg, NULL, 10, &info.maxx) < 0) {
                fprintf(stderr, "not a number: %s\n", optarg);
                exit(1);
            }
            break;
        case 'Y':
            if (qemu_strtoui(optarg, NULL, 10, &info.maxy) < 0) {
                fprintf(stderr, "not a number: %s\n", optarg);
                exit(1);
            }
            break;
        case 'd':
            if (qemu_strtoui(optarg, NULL, 10, &dpi) < 0) {
                fprintf(stderr, "not a number: %s\n", optarg);
                exit(1);
            }
            if (dpi == 0) {
                fprintf(stderr, "cannot be zero: %s\n", optarg);
                exit(1);
            }
            break;
        case 'v':
            info.vendor = optarg;
            break;
        case 'n':
            info.name = optarg;
            break;
        case 's':
            info.serial = optarg;
            break;
        case 'h':
            usage(stdout);
            exit(0);
        default:
            usage(stderr);
            exit(1);
        }
    }

    if (outfile == NULL) {
        outfile = stdout;
    }

    info.width_mm = qemu_edid_dpi_to_mm(dpi, info.prefx);
    info.height_mm = qemu_edid_dpi_to_mm(dpi, info.prefy);

    memset(blob, 0, sizeof(blob));
    qemu_edid_generate(blob, sizeof(blob), &info);
    size = qemu_edid_size(blob);
    fwrite(blob, size, 1, outfile);
    fflush(outfile);

    exit(0);
}
back to top