code: func (t *KVMsTable) update(c context.Context) error {
  	// Avoid using the database connection to prepare unnecessary statements.
  	if len(t.updates) == 0 {
  		return nil
  	}
  
  	db := database.Get(c)
  	// TODO(smut): Update IP address.
  	stmt, err := db.PrepareContext(c, `
  		UPDATE kvms
  		SET description = ?, mac_address = ?, state = ?, platform_id = ?, rack_id = ?
  		WHERE id = ?
  	`)
  	if err != nil {
  		return errors.Annotate(err, "failed to prepare statement").Err()
  	}
  	defer stmt.Close()
  
  	// Update each KVM in the table. It's more efficient to update the slice of
  	// KVMs once at the end rather than for each update, so use a defer.
  	updated := make(map[int64]*KVM, len(t.updates))
  	defer func() {
  		for _, kvm := range t.current {
  			if u, ok := updated[kvm.Id]; ok {
  				kvm.MacAddress = u.MacAddress
  				kvm.Description = u.Description
  				kvm.State = u.State
  				kvm.PlatformId = u.PlatformId
  				kvm.RackId = u.RackId
  			}
  		}
  	}()
  	for len(t.updates) > 0 {
  		kvm := t.updates[0]
  		if _, err := stmt.ExecContext(c, kvm.Description, kvm.MacAddress, kvm.State, kvm.PlatformId, kvm.RackId, kvm.Id); err != nil {
  			return errors.Annotate(err, "failed to update KVM %q", kvm.Name).Err()
  		}
  		updated[kvm.Id] = kvm
  		t.updates = t.updates[1:]
  		logging.Infof(c, "Updated KVM %q", kvm.Name)
  	}
  	return nil
  }
docs: // update updates all KVMs pending update in the database, clearing pending updates.
  // No-op unless computeChanges was called first. Idempotent until computeChanges is called again.