vstate: remove duplicate run_code test
This is already found in the kvm crate.
@@ -531,68 +531,4 @@ mod tests {
assert!(vm.memory_init(gm, &kvm).is_err());
}
-
- #[test]
- fn run_code() {
- use std::io::{self, Write};
- // This example based on https://lwn.net/Articles/658511/
- let code = [
- 0xba, 0xf8, 0x03, /* mov $0x3f8, %dx */
- 0x00, 0xd8, /* add %bl, %al */
- 0x04, b'0', /* add $'0', %al */
- 0xee, /* out %al, (%dx) */
- 0xb0, b'\n', /* mov $'\n', %al */
- 0xee, /* out %al, (%dx) */
- 0xf4, /* hlt */
- ];
-
- let mem_size = 0x1000;
- let load_addr = GuestAddress(0x1000);
- let mem = GuestMemory::new(&[(load_addr, mem_size)]).unwrap();
-
- let kvm = KvmContext::new().unwrap();
- let mut vm = Vm::new(kvm.fd()).expect("new vm failed");
- assert!(vm.memory_init(mem, &kvm).is_ok());
- vm.get_memory()
- .unwrap()
- .write_slice_at_addr(&code, load_addr)
- .expect("Writing code to memory failed.");
-
- let vcpu = Vcpu::new(
- 0,
- &vm,
- devices::Bus::new(),
- devices::Bus::new(),
- super::super::TimestampUs::default(),
- )
- .expect("new vcpu failed");
-
- let mut vcpu_sregs = vcpu.fd.get_sregs().expect("get sregs failed");
- assert_ne!(vcpu_sregs.cs.base, 0);
- assert_ne!(vcpu_sregs.cs.selector, 0);
- vcpu_sregs.cs.base = 0;
- vcpu_sregs.cs.selector = 0;
- vcpu.fd.set_sregs(&vcpu_sregs).expect("set sregs failed");
-
- let mut vcpu_regs = vcpu.fd.get_regs().expect("get regs failed");
- vcpu_regs.rip = 0x1000;
- vcpu_regs.rax = 2;
- vcpu_regs.rbx = 3;
- vcpu_regs.rflags = 2;
- vcpu.fd.set_regs(&vcpu_regs).expect("set regs failed");
-
- loop {
- match vcpu.fd.run().map_err(Error::VcpuRun).expect("run failed") {
- VcpuExit::IoOut(0x3f8, data) => {
- assert_eq!(data.len(), 1);
- io::stdout().write_all(data).unwrap();
- }
- VcpuExit::Hlt => {
- io::stdout().write_all(b"KVM_EXIT_HLT\n").unwrap();
- break;
- }
- r => panic!("unexpected exit reason: {:?}", r),
- }
- }
- }
}
