diff --git a/rpc.go b/rpc.go index 7ab6224..447e853 100644 --- a/rpc.go +++ b/rpc.go @@ -364,7 +364,8 @@ func (l *Libvirt) requestStream(proc uint32, program uint32, payload []byte, out } func (l *Libvirt) sendStream(serial uint32, proc uint32, program uint32, stream io.Reader, abort chan bool) error { - buf := make([]byte, 1<<22-24) + // Keep total packet length under 4 MiB to follow possible limitation in libvirt server code + buf := make([]byte, 4*MiB-constants.HeaderSize) for { select { case <-abort: diff --git a/units.go b/units.go new file mode 100644 index 0000000..c60d1b5 --- /dev/null +++ b/units.go @@ -0,0 +1,24 @@ +// Copyright 2016 The go-libvirt Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This module provides different units of measurement to make other +// code more readable. + +package libvirt + +const ( + B = 1 + KiB = 1024 * B + MiB = 1024 * KiB +)