Skip to content

Commit

Permalink
Misc bug fixes and logging improvements (#1530)
Browse files Browse the repository at this point in the history
* various small fixes/improvements

don't try typing extended vnc clipboard commands (fixes warning on connection to vm)
print hex for keysym character that couldn't be found
print hostname in "mistmatched miniccc" warning
add bidirectional-copy-paste to "vm info" output
fix tpm qemu arguments for newer qemu versions
include qemu std err in "unable to connect to qmp socket" error

* update default debian mirror in vmbetter

fixes #1529

* fix "vm clear tag <vm> <tag>" not clearing specific tag only

Closes #1535

* fix `vm cdrom change` on qemu 6+
  • Loading branch information
jacdavi authored Mar 26, 2024
1 parent d76fa44 commit f0b7fcc
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
16 changes: 9 additions & 7 deletions cmd/minimega/kvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,10 +781,12 @@ func (vm *KvmVM) connectVNC() error {
if err == nil {
// for cut text, send text immediately as string if not bi-directional
if cut, ok := msg.(*vnc.ClientCutText); ok && !vm.BidirectionalCopyPaste {
log.Info("sending text for ClientCutText: %s", cut.Text)
err = ns.Player.PlaybackString(vm.Name, vm.vncShim.Addr().String(), string(cut.Text))
if err != nil {
log.Warnln(err)
if cut.Length > 0 {
log.Info("sending text for ClientCutText: %s", cut.Text)
err = ns.Player.PlaybackString(vm.Name, vm.vncShim.Addr().String(), string(cut.Text))
if err != nil {
log.Warnln(err)
}
}
}
ns.Recorder.Route(vm.GetName(), msg)
Expand Down Expand Up @@ -988,8 +990,8 @@ func (vm *KvmVM) launch() error {
if err := vm.connectQMP(); err != nil {
// Failed to connect to qmp so clean up the process
cmd.Process.Kill()

return vm.setErrorf("unable to connect to qmp socket: %v", err)
// Qemu stderr likely contains reason
return vm.setErrorf("unable to connect to qmp socket: %v. qemu output: %v", err, sErr.String())
}

go vm.qmpLogger()
Expand Down Expand Up @@ -1349,7 +1351,7 @@ func (vm VMConfig) qemuArgs(id int, vmPath string) []string {

if vm.TpmSocketPath != "" {
args = append(args, "-chardev")
args = append(args, fmt.Sprintf("socket,id=chrtpm,path=%v,nowait", vm.TpmSocketPath))
args = append(args, fmt.Sprintf("socket,id=chrtpm,path=%v", vm.TpmSocketPath))
args = append(args, "-tpmdev")
args = append(args, "emulator,id=tpm0,chardev=chrtpm")
args = append(args, "-device")
Expand Down
2 changes: 1 addition & 1 deletion cmd/minimega/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var vmInfo = []string{
// kvm fields
"vcpus", "disks", "snapshot", "initrd", "kernel", "cdrom", "migrate",
"append", "serial-ports", "virtio-ports", "vnc_port", "usb-use-xhci",
"tpm-socket",
"tpm-socket", "bidirectional-copy-paste",
// container fields
"filesystem", "hostname", "init", "preinit", "fifo", "volume",
"console_port",
Expand Down
2 changes: 1 addition & 1 deletion cmd/minimega/vm_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func cliVMTag(ns *Namespace, c *minicli.Command, resp *minicli.Response) error {

func cliClearVMTag(ns *Namespace, c *minicli.Command, resp *minicli.Response) error {
// Get the specified tag name or use Wildcard if not provided
key, ok := c.StringArgs["key"]
key, ok := c.StringArgs["tag"]
if !ok {
key = Wildcard
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/vmbetter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

var (
f_debian_mirror = flag.String("mirror", "http://mirrors.ocf.berkeley.edu/debian", "path to the debian mirror to use")
f_debian_mirror = flag.String("mirror", "http://ftp.us.debian.org/debian", "path to the debian mirror to use")
f_noclean = flag.Bool("noclean", false, "do not remove build directory")
f_stage1 = flag.Bool("1", false, "stop after stage one, and copy build files to <config>_stage1")
f_stage2 = flag.String("2", "", "complete stage 2 from an existing stage 1 directory")
Expand Down
10 changes: 5 additions & 5 deletions internal/qmp/qmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (q *Conn) BlockdevEject(device string, force bool) error {
}
v := <-q.messageSync
if !success(v) {
return errors.New("eject")
return fmt.Errorf("eject failed: %v", v)
}
return nil
}
Expand All @@ -228,10 +228,10 @@ func (q *Conn) BlockdevChange(device, path string) error {
return ERR_READY
}
s := map[string]interface{}{
"execute": "change",
"execute": "blockdev-change-medium",
"arguments": map[string]interface{}{
"device": device,
"target": path,
"device": device,
"filename": path,
},
}
err := q.write(s)
Expand All @@ -240,7 +240,7 @@ func (q *Conn) BlockdevChange(device, path string) error {
}
v := <-q.messageSync
if !success(v) {
return errors.New("change")
return fmt.Errorf("change failed: %v", v)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ron/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func (s *Server) handshake(conn net.Conn) (*client, error) {
c.Namespace = namespace

if m.Client.Version != version.Revision {
log.Warn("mismatched miniccc version: %v", m.Client.Version)
log.Warn("mismatched miniccc version on %v: %v", m.Client.Hostname, m.Client.Version)
}

if majorVersion(m.Version) > 0 {
Expand Down
8 changes: 5 additions & 3 deletions internal/vnc/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ func ReadClientMessage(r io.Reader) (interface{}, error) {
msg = msg2
case TypeClientCutText:
msg2 := &ClientCutText{_ClientCutText: *msg.(*_ClientCutText)}
if msg2.Length < 0 {
msg2.Length = -msg2.Length
length := msg2.Length
// negative length used for extended pseudo-encoding
if length < 0 {
length = -length
}
msg2.Text = make([]uint8, msg2.Length)
msg2.Text = make([]uint8, length)

err = binary.Read(r, binary.BigEndian, &msg2.Text)
msg = msg2
Expand Down
2 changes: 1 addition & 1 deletion internal/vnc/keysym.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func asciiCharToKeysymString(c rune) (string, error) {
}
keysym, err := xKeysymToString(uint32(c))
if err != nil {
return "uint32(0)", fmt.Errorf("character has no keysym mapping: %c", c)
return "uint32(0)", fmt.Errorf("character has no keysym mapping: %c [%x]", c, c)
}
return keysym, nil
}
Expand Down

0 comments on commit f0b7fcc

Please sign in to comment.