microvm.c (f21f1cfeb94b94ce044726856c291bed9391e3a4) microvm.c (eac7a7791bb6d719233deed750034042318ffd56)
1/*
2 * Copyright (c) 2018 Intel Corporation
3 * Copyright (c) 2019 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2 or later, as published by the Free Software Foundation.
8 *

--- 364 unchanged lines hidden (view full) ---

373}
374
375static void microvm_fix_kernel_cmdline(MachineState *machine)
376{
377 X86MachineState *x86ms = X86_MACHINE(machine);
378 MicrovmMachineState *mms = MICROVM_MACHINE(machine);
379 BusState *bus;
380 BusChild *kid;
1/*
2 * Copyright (c) 2018 Intel Corporation
3 * Copyright (c) 2019 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2 or later, as published by the Free Software Foundation.
8 *

--- 364 unchanged lines hidden (view full) ---

373}
374
375static void microvm_fix_kernel_cmdline(MachineState *machine)
376{
377 X86MachineState *x86ms = X86_MACHINE(machine);
378 MicrovmMachineState *mms = MICROVM_MACHINE(machine);
379 BusState *bus;
380 BusChild *kid;
381 char *cmdline;
381 char *cmdline, *existing_cmdline;
382 size_t len;
382
383 /*
384 * Find MMIO transports with attached devices, and add them to the kernel
385 * command line.
386 *
387 * Yes, this is a hack, but one that heavily improves the UX without
388 * introducing any significant issues.
389 */
383
384 /*
385 * Find MMIO transports with attached devices, and add them to the kernel
386 * command line.
387 *
388 * Yes, this is a hack, but one that heavily improves the UX without
389 * introducing any significant issues.
390 */
390 cmdline = g_strdup(machine->kernel_cmdline);
391 existing_cmdline = fw_cfg_read_bytes_ptr(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA);
392 cmdline = g_strdup(existing_cmdline);
391 bus = sysbus_get_default();
392 QTAILQ_FOREACH(kid, &bus->children, sibling) {
393 DeviceState *dev = kid->child;
394 ObjectClass *class = object_get_class(OBJECT(dev));
395
396 if (class == object_class_by_name(TYPE_VIRTIO_MMIO)) {
397 VirtIOMMIOProxy *mmio = VIRTIO_MMIO(OBJECT(dev));
398 VirtioBusState *mmio_virtio_bus = &mmio->bus;

--- 7 unchanged lines hidden (view full) ---

406 g_free(mmio_cmdline);
407 g_free(cmdline);
408 cmdline = newcmd;
409 }
410 }
411 }
412 }
413
393 bus = sysbus_get_default();
394 QTAILQ_FOREACH(kid, &bus->children, sibling) {
395 DeviceState *dev = kid->child;
396 ObjectClass *class = object_get_class(OBJECT(dev));
397
398 if (class == object_class_by_name(TYPE_VIRTIO_MMIO)) {
399 VirtIOMMIOProxy *mmio = VIRTIO_MMIO(OBJECT(dev));
400 VirtioBusState *mmio_virtio_bus = &mmio->bus;

--- 7 unchanged lines hidden (view full) ---

408 g_free(mmio_cmdline);
409 g_free(cmdline);
410 cmdline = newcmd;
411 }
412 }
413 }
414 }
415
414 fw_cfg_modify_i32(x86ms->fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(cmdline) + 1);
415 fw_cfg_modify_string(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA, cmdline);
416
416 len = strlen(cmdline);
417 if (len > VIRTIO_CMDLINE_TOTAL_MAX_LEN + strlen(existing_cmdline)) {
418 fprintf(stderr, "qemu: virtio mmio cmdline too large, skipping\n");
419 } else {
420 memcpy(existing_cmdline, cmdline, len + 1);
421 }
417 g_free(cmdline);
418}
419
420static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev,
421 DeviceState *dev, Error **errp)
422{
423 X86CPU *cpu = X86_CPU(dev);
424

--- 312 unchanged lines hidden ---
422 g_free(cmdline);
423}
424
425static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev,
426 DeviceState *dev, Error **errp)
427{
428 X86CPU *cpu = X86_CPU(dev);
429

--- 312 unchanged lines hidden ---