microvm.c (526947e496e4447d74b8d42415e2847481c5043d) | microvm.c (b34f2fd17e4276ac0a75f8d72485a0236a740954) |
---|---|
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 * --- 362 unchanged lines hidden (view full) --- 371} 372 373static void microvm_fix_kernel_cmdline(MachineState *machine) 374{ 375 X86MachineState *x86ms = X86_MACHINE(machine); 376 MicrovmMachineState *mms = MICROVM_MACHINE(machine); 377 BusState *bus; 378 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 * --- 362 unchanged lines hidden (view full) --- 371} 372 373static void microvm_fix_kernel_cmdline(MachineState *machine) 374{ 375 X86MachineState *x86ms = X86_MACHINE(machine); 376 MicrovmMachineState *mms = MICROVM_MACHINE(machine); 377 BusState *bus; 378 BusChild *kid; |
379 char *cmdline, *existing_cmdline; 380 size_t len; | 379 char *cmdline; |
381 382 /* 383 * Find MMIO transports with attached devices, and add them to the kernel 384 * command line. 385 * 386 * Yes, this is a hack, but one that heavily improves the UX without 387 * introducing any significant issues. 388 */ | 380 381 /* 382 * Find MMIO transports with attached devices, and add them to the kernel 383 * command line. 384 * 385 * Yes, this is a hack, but one that heavily improves the UX without 386 * introducing any significant issues. 387 */ |
389 existing_cmdline = fw_cfg_read_bytes_ptr(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA); 390 cmdline = g_strdup(existing_cmdline); | 388 cmdline = g_strdup(machine->kernel_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 | 389 bus = sysbus_get_default(); 390 QTAILQ_FOREACH(kid, &bus->children, sibling) { 391 DeviceState *dev = kid->child; 392 ObjectClass *class = object_get_class(OBJECT(dev)); 393 394 if (class == object_class_by_name(TYPE_VIRTIO_MMIO)) { 395 VirtIOMMIOProxy *mmio = VIRTIO_MMIO(OBJECT(dev)); 396 VirtioBusState *mmio_virtio_bus = &mmio->bus; --- 7 unchanged lines hidden (view full) --- 404 g_free(mmio_cmdline); 405 g_free(cmdline); 406 cmdline = newcmd; 407 } 408 } 409 } 410 } 411 |
414 len = strlen(cmdline); 415 if (len > VIRTIO_CMDLINE_TOTAL_MAX_LEN + strlen(existing_cmdline)) { 416 fprintf(stderr, "qemu: virtio mmio cmdline too large, skipping\n"); 417 } else { 418 memcpy(existing_cmdline, cmdline, len + 1); 419 } | 412 fw_cfg_modify_i32(x86ms->fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(cmdline) + 1); 413 fw_cfg_modify_string(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA, cmdline); 414 |
420 g_free(cmdline); 421} 422 423static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev, 424 DeviceState *dev, Error **errp) 425{ 426 X86CPU *cpu = X86_CPU(dev); 427 --- 312 unchanged lines hidden --- | 415 g_free(cmdline); 416} 417 418static void microvm_device_pre_plug_cb(HotplugHandler *hotplug_dev, 419 DeviceState *dev, Error **errp) 420{ 421 X86CPU *cpu = X86_CPU(dev); 422 --- 312 unchanged lines hidden --- |