kola/qemuexec: Add secondary-nics argument
Adding a new argument "secondary-nics" to cosa kola qemuexec command, to
allow adding non privileged secondary-nics via cosa
The mac value of secondary-nics is set to 16.
This functionality is also documented in a issue [1].
[1]
@@ -65,8 +65,12 @@ var (
devshellConsole bool
consoleFile string
+
+ secondaryNics int
)
+const maxSecondaryNics = 16
+
func init() {
root.AddCommand(cmdQemuExec)
cmdQemuExec.Flags().StringVarP(&knetargs, "knetargs", "", "", "Arguments for Ignition networking on kernel commandline")
@@ -87,6 +91,7 @@ func init() {
cmdQemuExec.Flags().BoolVarP(&forceConfigInjection, "inject-ignition", "", false, "Force injecting Ignition config using guestfs")
cmdQemuExec.Flags().BoolVar(&propagateInitramfsFailure, "propagate-initramfs-failure", false, "Error out if the system fails in the initramfs")
cmdQemuExec.Flags().StringVarP(&consoleFile, "console-to-file", "", "", "Filepath in which to save serial console logs")
+ cmdQemuExec.Flags().IntVarP(&secondaryNics, "secondary-nics", "", 0, "Number of secondary NICs to add")
}
@@ -309,6 +314,12 @@ func runQemuExec(cmd *cobra.Command, args []string) error {
}
builder.EnableUsermodeNetworking(h)
}
+ if secondaryNics != 0 {
+ if secondaryNics < 0 || secondaryNics > maxSecondaryNics {
+ return errors.Wrapf(nil, "secondary-nics value cannot be negative or greater than %d", maxSecondaryNics)
+ }
+ builder.AddSecondaryNics(secondaryNics)
+ }
builder.InheritConsole = true
builder.ConsoleFile = consoleFile
builder.Append(args...)
