1 /*
2  * Generic Virtual-Device Fuzzing Target Configs
3  *
4  * Copyright Red Hat Inc., 2020
5  *
6  * Authors:
7  *  Alexander Bulekov   <alxndr@bu.edu>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10  * See the COPYING file in the top-level directory.
11  */
12 
13 #ifndef GENERIC_FUZZ_CONFIGS_H
14 #define GENERIC_FUZZ_CONFIGS_H
15 
16 
17 typedef struct generic_fuzz_config {
18     const char *name, *args, *objects;
19     gchar* (*argfunc)(void); /* Result must be freeable by g_free() */
20 } generic_fuzz_config;
21 
22 static inline gchar *generic_fuzzer_virtio_9p_args(void){
23     g_autofree char *tmpdir = g_dir_make_tmp("qemu-fuzz.XXXXXX", NULL);
24     g_assert_nonnull(tmpdir);
25 
26     return g_strdup_printf("-machine q35 -nodefaults "
27     "-device virtio-9p,fsdev=hshare,mount_tag=hshare "
28     "-fsdev local,id=hshare,path=%s,security_model=mapped-xattr,"
29     "writeout=immediate,fmode=0600,dmode=0700", tmpdir);
30 }
31 
32 const generic_fuzz_config predefined_configs[] = {
33     {
34         .name = "virtio-net-pci-slirp",
35         .args = "-M q35 -nodefaults "
36         "-device virtio-net,netdev=net0 -netdev user,id=net0",
37         .objects = "virtio*",
38     },{
39         .name = "virtio-blk",
40         .args = "-machine q35 -device virtio-blk,drive=disk0 "
41         "-drive file=null-co://,id=disk0,if=none,format=raw",
42         .objects = "virtio*",
43     },{
44         .name = "virtio-scsi",
45         .args = "-machine q35 -device virtio-scsi,num_queues=8 "
46         "-device scsi-hd,drive=disk0 "
47         "-drive file=null-co://,id=disk0,if=none,format=raw",
48         .objects = "scsi* virtio*",
49     },{
50         .name = "virtio-gpu",
51         .args = "-machine q35 -nodefaults -device virtio-gpu",
52         .objects = "virtio*",
53     },{
54         .name = "virtio-vga",
55         .args = "-machine q35 -nodefaults -device virtio-vga",
56         .objects = "virtio*",
57     },{
58         .name = "virtio-rng",
59         .args = "-machine q35 -nodefaults -device virtio-rng",
60         .objects = "virtio*",
61     },{
62         .name = "virtio-balloon",
63         .args = "-machine q35 -nodefaults -device virtio-balloon",
64         .objects = "virtio*",
65     },{
66         .name = "virtio-serial",
67         .args = "-machine q35 -nodefaults -device virtio-serial",
68         .objects = "virtio*",
69     },{
70         .name = "virtio-mouse",
71         .args = "-machine q35 -nodefaults -device virtio-mouse",
72         .objects = "virtio*",
73     },{
74         .name = "virtio-9p",
75         .argfunc = generic_fuzzer_virtio_9p_args,
76         .objects = "virtio*",
77     },{
78         .name = "virtio-9p-synth",
79         .args = "-machine q35 -nodefaults "
80         "-device virtio-9p,fsdev=hshare,mount_tag=hshare "
81         "-fsdev synth,id=hshare",
82         .objects = "virtio*",
83     },{
84         .name = "e1000",
85         .args = "-M q35 -nodefaults "
86         "-device e1000,netdev=net0 -netdev user,id=net0",
87         .objects = "e1000",
88     },{
89         .name = "e1000e",
90         .args = "-M q35 -nodefaults "
91         "-device e1000e,netdev=net0 -netdev user,id=net0",
92         .objects = "e1000e",
93     },{
94         .name = "cirrus-vga",
95         .args = "-machine q35 -nodefaults -device cirrus-vga",
96         .objects = "cirrus*",
97     },{
98         .name = "bochs-display",
99         .args = "-machine q35 -nodefaults -device bochs-display",
100         .objects = "bochs*",
101     },{
102         .name = "intel-hda",
103         .args = "-machine q35 -nodefaults -device intel-hda,id=hda0 "
104         "-device hda-output,bus=hda0.0 -device hda-micro,bus=hda0.0 "
105         "-device hda-duplex,bus=hda0.0",
106         .objects = "intel-hda",
107     },{
108         .name = "ide-hd",
109         .args = "-machine pc -nodefaults "
110         "-drive file=null-co://,if=none,format=raw,id=disk0 "
111         "-device ide-hd,drive=disk0",
112         .objects = "*ide*",
113     },{
114         .name = "ide-atapi",
115         .args = "-machine pc -nodefaults "
116         "-drive file=null-co://,if=none,format=raw,id=disk0 "
117         "-device ide-cd,drive=disk0",
118         .objects = "*ide*",
119     },{
120         .name = "ahci-hd",
121         .args = "-machine q35 -nodefaults "
122         "-drive file=null-co://,if=none,format=raw,id=disk0 "
123         "-device ide-hd,drive=disk0",
124         .objects = "*ahci*",
125     },{
126         .name = "ahci-atapi",
127         .args = "-machine q35 -nodefaults "
128         "-drive file=null-co://,if=none,format=raw,id=disk0 "
129         "-device ide-cd,drive=disk0",
130         .objects = "*ahci*",
131     },{
132         .name = "floppy",
133         .args = "-machine pc -nodefaults -device floppy,id=floppy0 "
134         "-drive id=disk0,file=null-co://,file.read-zeroes=on,if=none,format=raw "
135         "-device floppy,drive=disk0,drive-type=288",
136         .objects = "fd* floppy* i8257",
137     },{
138         .name = "xhci",
139         .args = "-machine q35 -nodefaults "
140         "-drive file=null-co://,if=none,format=raw,id=disk0 "
141         "-device qemu-xhci,id=xhci -device usb-tablet,bus=xhci.0 "
142         "-device usb-bot -device usb-storage,drive=disk0 "
143         "-chardev null,id=cd0 -chardev null,id=cd1 "
144         "-device usb-braille,chardev=cd0 -device usb-ccid -device usb-ccid "
145         "-device usb-kbd -device usb-mouse -device usb-serial,chardev=cd1 "
146         "-device usb-tablet -device usb-wacom-tablet -device usb-audio",
147         .objects = "*usb* *uhci* *xhci*",
148     },{
149         .name = "pc-i440fx",
150         .args = "-machine pc",
151         .objects = "*",
152     },{
153         .name = "pc-q35",
154         .args = "-machine q35",
155         .objects = "*",
156     },{
157         .name = "vmxnet3",
158         .args = "-machine q35 -nodefaults "
159         "-device vmxnet3,netdev=net0 -netdev user,id=net0",
160         .objects = "vmxnet3"
161     },{
162         .name = "ne2k_pci",
163         .args = "-machine q35 -nodefaults "
164         "-device ne2k_pci,netdev=net0 -netdev user,id=net0",
165         .objects = "ne2k*"
166     },{
167         .name = "pcnet",
168         .args = "-machine q35 -nodefaults "
169         "-device pcnet,netdev=net0 -netdev user,id=net0",
170         .objects = "pcnet"
171     },{
172         .name = "rtl8139",
173         .args = "-machine q35 -nodefaults "
174         "-device rtl8139,netdev=net0 -netdev user,id=net0",
175         .objects = "rtl8139"
176     },{
177         .name = "i82550",
178         .args = "-machine q35 -nodefaults "
179         "-device i82550,netdev=net0 -netdev user,id=net0",
180         .objects = "i8255*"
181     },{
182         .name = "sdhci-v3",
183         .args = "-nodefaults -device sdhci-pci,sd-spec-version=3 "
184         "-device sd-card,drive=mydrive "
185         "-drive if=none,index=0,file=null-co://,format=raw,id=mydrive -nographic",
186         .objects = "sd*"
187     },{
188         .name = "ehci",
189         .args = "-machine q35 -nodefaults "
190         "-device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
191         "multifunction=on,id=ich9-ehci-1 "
192         "-device ich9-usb-uhci1,bus=pcie.0,addr=1d.0,"
193         "multifunction=on,masterbus=ich9-ehci-1.0,firstport=0 "
194         "-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
195         "multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
196         "-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
197         "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
198         "-drive if=none,id=usbcdrom,media=cdrom "
199         "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
200         "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom",
201         .objects = "*usb* *hci*",
202     },{
203         .name = "ohci",
204         .args = "-machine q35 -nodefaults  -device pci-ohci -device usb-kbd",
205         .objects = "*usb* *ohci*",
206     },{
207         .name = "megaraid",
208         .args = "-machine q35 -nodefaults -device megasas -device scsi-cd,drive=null0 "
209         "-blockdev driver=null-co,read-zeroes=on,node-name=null0",
210         .objects = "megasas*",
211     },{
212         .name = "am53c974",
213         .args = "-device am53c974,id=scsi -device scsi-hd,drive=disk0 "
214                  "-drive id=disk0,if=none,file=null-co://,format=raw "
215                  "-nodefaults",
216         .objects = "*esp* *scsi* *am53c974*",
217     },{
218         .name = "ac97",
219         .args = "-machine q35 -nodefaults "
220         "-device ac97,audiodev=snd0 -audiodev none,id=snd0 -nodefaults",
221         .objects = "ac97*",
222     },{
223         .name = "cs4231a",
224         .args = "-machine q35 -nodefaults "
225         "-device cs4231a,audiodev=snd0 -audiodev none,id=snd0 -nodefaults",
226         .objects = "cs4231a* i8257*",
227     },{
228         .name = "es1370",
229         .args = "-machine q35 -nodefaults "
230         "-device es1370,audiodev=snd0 -audiodev none,id=snd0 -nodefaults",
231         .objects = "es1370*",
232     },{
233         .name = "sb16",
234         .args = "-machine q35 -nodefaults "
235         "-device sb16,audiodev=snd0 -audiodev none,id=snd0 -nodefaults",
236         .objects = "sb16* i8257*",
237     },{
238         .name = "parallel",
239         .args = "-machine q35 -nodefaults "
240         "-parallel file:/dev/null",
241         .objects = "parallel*",
242     }
243 };
244 
245 #endif
246