| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | #pragma once |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #include "macro.h" |
| 7 | |
| 8 | /* Helpers for writing QEMU -readconfig INI-style config files. |
| 9 | * |
| 10 | * QEMU config format: |
| 11 | * [type "id"] |
| 12 | * key = "value" |
| 13 | * |
| 14 | * Usage: |
| 15 | * qemu_config_section(f, "device", "rng0", |
| 16 | * "driver", "virtio-rng-pci", |
| 17 | * "rng", "rng0"); |
| 18 | */ |
| 19 | |
| 20 | /* Write a single key = "value" pair (for conditional keys added after a section header) */ |
| 21 | int qemu_config_key(FILE *f, const char *key, const char *value); |
| 22 | |
| 23 | /* Write a single key with a printf-formatted value */ |
| 24 | int qemu_config_keyf(FILE *f, const char *key, const char *format, ...) _printf_(3, 4); |
| 25 | |
| 26 | /* Write a section header with key-value pairs. Varargs are alternating key, value strings. */ |
| 27 | int qemu_config_section_impl(FILE *f, const char *type, const char *id, ...) _sentinel_; |
| 28 | #define qemu_config_section(...) qemu_config_section_impl(__VA_ARGS__, NULL) |